2013-06-27 16:15:36 +00:00
|
|
|
openerp.website = function(instance) {
|
2013-08-05 08:26:38 +00:00
|
|
|
|
|
|
|
instance.web.ActionManager.include({
|
|
|
|
// Temporary fix until un-webclientization of the editorbar
|
|
|
|
ir_actions_client: function (action) {
|
|
|
|
if (instance.web.client_actions.get_object(action.tag)) {
|
|
|
|
return this._super.apply(this, arguments);
|
|
|
|
} else {
|
|
|
|
console.warn("Action '%s' not found in registry", action.tag);
|
|
|
|
return $.when();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-07-25 14:55:05 +00:00
|
|
|
var _lt = instance.web._lt;
|
2013-07-31 15:05:11 +00:00
|
|
|
var QWeb = instance.web.qweb;
|
2013-06-27 16:15:36 +00:00
|
|
|
instance.website.EditorBar = instance.web.Widget.extend({
|
|
|
|
template: 'Website.EditorBar',
|
|
|
|
events: {
|
2013-07-02 17:16:14 +00:00
|
|
|
'click button[data-action=edit]': 'edit',
|
2013-06-27 16:15:36 +00:00
|
|
|
'click button[data-action=save]': 'save',
|
|
|
|
'click button[data-action=cancel]': 'cancel',
|
2013-07-02 21:00:35 +00:00
|
|
|
'click button[data-action=snippet]': 'snippet',
|
2013-06-27 16:15:36 +00:00
|
|
|
},
|
|
|
|
container: 'body',
|
2013-07-25 14:55:05 +00:00
|
|
|
init: function () {
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
this.saving_mutex = new $.Mutex();
|
|
|
|
},
|
2013-08-11 14:06:19 +00:00
|
|
|
customize_setup: function() {
|
|
|
|
var self = this;
|
2013-08-12 10:55:21 +00:00
|
|
|
var view_name = $('html').data('view-xmlid');
|
|
|
|
var menu = $('#customize-menu');
|
2013-08-11 14:06:19 +00:00
|
|
|
this.$('#customize-menu-button').click(function(event) {
|
2013-08-12 10:55:21 +00:00
|
|
|
menu.empty();
|
|
|
|
self.rpc('/website/customize_template_get', { 'xml_id': view_name }).then(
|
2013-08-11 14:06:19 +00:00
|
|
|
function(result) {
|
2013-08-12 10:55:21 +00:00
|
|
|
_.each(result, function (item) {
|
2013-08-11 14:06:19 +00:00
|
|
|
if (item.header) {
|
2013-08-12 10:55:21 +00:00
|
|
|
menu.append('<li class="nav-header">' + item.name + '</li>');
|
2013-08-11 14:06:19 +00:00
|
|
|
} else {
|
2013-08-12 10:55:21 +00:00
|
|
|
menu.append(_.str.sprintf('<li><a href="#" data-view-id="%s"><strong class="icon-check%s"></strong> %s</a></li>',
|
|
|
|
item.id, item.active ? '' : '-empty', item.name));
|
2013-08-11 14:06:19 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-08-12 10:55:21 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
menu.on('click', 'a', function (event) {
|
|
|
|
var view_id = $(event.target).data('view-id');
|
|
|
|
self.rpc('/website/customize_template_toggle', {
|
|
|
|
'view_id': view_id
|
|
|
|
}).then( function(result) {
|
|
|
|
window.location.reload();
|
|
|
|
});
|
2013-08-11 14:06:19 +00:00
|
|
|
});
|
|
|
|
},
|
2013-06-27 16:15:36 +00:00
|
|
|
start: function() {
|
|
|
|
var self = this;
|
2013-07-25 14:55:05 +00:00
|
|
|
|
2013-08-11 10:35:14 +00:00
|
|
|
this.$('#website-top-edit').hide();
|
|
|
|
this.$('#website-top-view').show();
|
|
|
|
|
|
|
|
$('.dropdown-toggle').dropdown();
|
2013-08-11 14:06:19 +00:00
|
|
|
this.customize_setup();
|
2013-08-11 10:35:14 +00:00
|
|
|
|
2013-07-25 14:55:05 +00:00
|
|
|
this.$buttons = {
|
|
|
|
edit: this.$('button[data-action=edit]'),
|
|
|
|
save: this.$('button[data-action=save]'),
|
|
|
|
cancel: this.$('button[data-action=cancel]'),
|
|
|
|
snippet: this.$('button[data-action=snippet]'),
|
|
|
|
};
|
|
|
|
|
|
|
|
this.rte = new instance.website.RTE(this);
|
|
|
|
this.rte.on('change', this, this.proxy('rte_changed'));
|
2013-07-23 13:15:43 +00:00
|
|
|
|
2013-08-19 09:25:07 +00:00
|
|
|
this.snippets = new instance.website.Snippets();
|
|
|
|
this.snippets.appendTo($("body"));
|
|
|
|
|
2013-07-25 14:55:05 +00:00
|
|
|
return $.when(
|
|
|
|
this._super.apply(this, arguments),
|
2013-07-29 14:56:26 +00:00
|
|
|
this.rte.insertBefore(this.$buttons.snippet.parent())
|
2013-07-25 14:55:05 +00:00
|
|
|
);
|
2013-07-02 17:16:14 +00:00
|
|
|
},
|
|
|
|
edit: function () {
|
2013-08-11 10:35:14 +00:00
|
|
|
this.$buttons.edit.prop('disabled', true);
|
|
|
|
this.$('#website-top-view').hide();
|
|
|
|
this.$('#website-top-edit').show();
|
|
|
|
|
|
|
|
// this.$buttons.cancel.add(this.$buttons.snippet).prop('disabled', false)
|
|
|
|
// .add(this.$buttons.save)
|
|
|
|
// .parent().show();
|
|
|
|
//
|
2013-07-26 11:37:42 +00:00
|
|
|
// TODO: span edition changing edition state (save button)
|
2013-07-30 15:09:55 +00:00
|
|
|
var $editables = $('[data-oe-model]')
|
2013-07-31 09:15:13 +00:00
|
|
|
.not('link, script')
|
|
|
|
// FIXME: propagation should make "meta" blocks non-editable in the first place...
|
|
|
|
.not('.oe_snippet_editor')
|
|
|
|
.prop('contentEditable', true)
|
2013-07-30 15:09:55 +00:00
|
|
|
.addClass('oe_editable');
|
2013-08-13 13:25:47 +00:00
|
|
|
var $rte_ables = $editables.not('[data-oe-type]');
|
2013-07-30 15:09:55 +00:00
|
|
|
var $raw_editables = $editables.not($rte_ables);
|
|
|
|
|
2013-07-31 14:06:31 +00:00
|
|
|
// temporary fix until we fix ckeditor
|
|
|
|
$raw_editables.each(function () {
|
|
|
|
$(this).parents().add($(this).find('*')).on('click', function(ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
ev.stopPropagation();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-07-30 15:09:55 +00:00
|
|
|
this.rte.start_edition($rte_ables);
|
|
|
|
$raw_editables.on('keydown keypress cut paste', function (e) {
|
|
|
|
var $target = $(e.target);
|
|
|
|
if ($target.hasClass('oe_dirty')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$target.addClass('oe_dirty');
|
|
|
|
this.$buttons.save.prop('disabled', false);
|
|
|
|
}.bind(this));
|
2013-07-25 14:55:05 +00:00
|
|
|
},
|
|
|
|
rte_changed: function () {
|
|
|
|
this.$buttons.save.prop('disabled', false);
|
2013-06-27 16:15:36 +00:00
|
|
|
},
|
|
|
|
save: function () {
|
|
|
|
var self = this;
|
|
|
|
var defs = [];
|
2013-07-03 01:51:09 +00:00
|
|
|
$('.oe_dirty').each(function (i, v) {
|
2013-06-27 16:15:36 +00:00
|
|
|
var $el = $(this);
|
2013-07-03 12:01:14 +00:00
|
|
|
// TODO: Add a queue with concurrency limit in webclient
|
|
|
|
// https://github.com/medikoo/deferred/blob/master/lib/ext/function/gate.js
|
|
|
|
var def = self.saving_mutex.exec(function () {
|
2013-07-03 01:51:09 +00:00
|
|
|
return self.saveElement($el).then(function () {
|
|
|
|
$el.removeClass('oe_dirty');
|
|
|
|
}).fail(function () {
|
|
|
|
var data = $el.data();
|
|
|
|
console.error(_.str.sprintf('Could not save %s#%d#%s', data.oeModel, data.oeId, data.oeField));
|
|
|
|
});
|
2013-06-27 16:15:36 +00:00
|
|
|
});
|
|
|
|
defs.push(def);
|
|
|
|
});
|
|
|
|
return $.when.apply(null, defs).then(function () {
|
2013-07-02 19:39:59 +00:00
|
|
|
window.location.reload();
|
2013-06-27 16:15:36 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
saveElement: function ($el) {
|
|
|
|
var data = $el.data();
|
2013-07-02 18:48:23 +00:00
|
|
|
var html = $el.html();
|
|
|
|
var xpath = data.oeXpath;
|
|
|
|
if (xpath) {
|
|
|
|
var $w = $el.clone();
|
2013-07-24 12:36:26 +00:00
|
|
|
$w.removeClass('oe_dirty');
|
2013-07-02 18:48:23 +00:00
|
|
|
_.each(['model', 'id', 'field', 'xpath'], function(d) {$w.removeAttr('data-oe-' + d);});
|
2013-07-24 12:36:26 +00:00
|
|
|
$w
|
|
|
|
.removeClass('oe_editable')
|
|
|
|
.prop('contentEditable', false);
|
2013-07-02 18:48:23 +00:00
|
|
|
html = $w.wrap('<div>').parent().html();
|
|
|
|
}
|
|
|
|
return (new instance.web.DataSet(this, 'ir.ui.view')).call('save', [data.oeModel, data.oeId, data.oeField, html, xpath]);
|
2013-06-27 16:15:36 +00:00
|
|
|
},
|
|
|
|
cancel: function () {
|
2013-07-02 19:39:59 +00:00
|
|
|
window.location.reload();
|
2013-07-02 21:00:35 +00:00
|
|
|
},
|
|
|
|
snippet: function (ev) {
|
2013-08-19 09:25:07 +00:00
|
|
|
this.snippets.toggle();
|
2013-07-02 21:00:35 +00:00
|
|
|
},
|
2013-06-27 16:15:36 +00:00
|
|
|
});
|
|
|
|
|
2013-07-25 14:55:05 +00:00
|
|
|
instance.website.RTE = instance.web.Widget.extend({
|
|
|
|
tagName: 'li',
|
2013-08-07 11:59:05 +00:00
|
|
|
id: 'oe_rte_toolbar',
|
2013-07-29 14:38:42 +00:00
|
|
|
className: 'oe_right oe_rte_toolbar',
|
2013-07-25 14:55:05 +00:00
|
|
|
// editor.ui.items -> possible commands &al
|
|
|
|
// editor.applyStyle(new CKEDITOR.style({element: "span",styles: {color: "#(color)"},overrides: [{element: "font",attributes: {color: null}}]}, {color: '#ff0000'}));
|
|
|
|
|
|
|
|
start_edition: function ($elements) {
|
|
|
|
var self = this;
|
2013-07-30 14:36:43 +00:00
|
|
|
this.snippet_carousel();
|
2013-07-25 14:55:05 +00:00
|
|
|
$elements
|
2013-07-26 13:44:59 +00:00
|
|
|
.not('span, [data-oe-type]')
|
2013-07-25 14:55:05 +00:00
|
|
|
.each(function () {
|
|
|
|
var $this = $(this);
|
|
|
|
CKEDITOR.inline(this, self._config()).on('change', function () {
|
|
|
|
$this.addClass('oe_dirty');
|
|
|
|
self.trigger('change', this, null);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_current_editor: function () {
|
|
|
|
return CKEDITOR.currentInstance;
|
|
|
|
},
|
|
|
|
_config: function () {
|
2013-07-31 15:07:33 +00:00
|
|
|
var removed_plugins = [
|
|
|
|
// remove custom context menu
|
|
|
|
'contextmenu,tabletools,liststyle',
|
|
|
|
// magicline captures mousein/mouseout => draggable does not work
|
|
|
|
'magicline'
|
|
|
|
];
|
2013-07-25 14:55:05 +00:00
|
|
|
return {
|
2013-08-13 13:41:44 +00:00
|
|
|
// Disable auto-generated titles
|
|
|
|
// FIXME: accessibility, need to generate user-sensible title, used for @title and @aria-label
|
|
|
|
title: false,
|
2013-07-31 15:07:33 +00:00
|
|
|
removePlugins: removed_plugins.join(','),
|
2013-07-25 14:55:05 +00:00
|
|
|
uiColor: '',
|
|
|
|
// Ensure no config file is loaded
|
|
|
|
customConfig: '',
|
|
|
|
// Disable ACF
|
|
|
|
allowedContent: true,
|
2013-07-31 09:01:51 +00:00
|
|
|
// Don't insert paragraphs around content in e.g. <li>
|
|
|
|
autoParagraph: false,
|
2013-07-31 12:13:43 +00:00
|
|
|
filebrowserImageUploadUrl: "/website/attach",
|
2013-08-07 11:59:05 +00:00
|
|
|
// Support for sharedSpaces in 4.x
|
|
|
|
extraPlugins: 'sharedspace',
|
|
|
|
// Place toolbar in controlled location
|
|
|
|
sharedSpaces: { top: 'oe_rte_toolbar' },
|
|
|
|
toolbar: [
|
2013-08-09 13:13:52 +00:00
|
|
|
{name: 'basicstyles', items: [
|
2013-08-07 11:59:05 +00:00
|
|
|
"Bold", "Italic", "Underline", "Strike", "Subscript",
|
2013-08-09 13:13:52 +00:00
|
|
|
"Superscript", "TextColor", "BGColor", "RemoveFormat"
|
2013-08-09 13:23:16 +00:00
|
|
|
]},{
|
2013-08-09 13:13:52 +00:00
|
|
|
name: 'span', items: [
|
2013-08-07 11:59:05 +00:00
|
|
|
"Link", "Unlink", "Blockquote", "BulletedList",
|
2013-08-09 13:13:52 +00:00
|
|
|
"NumberedList", "Indent", "Outdent",
|
2013-08-09 13:23:16 +00:00
|
|
|
]},{
|
2013-08-09 13:13:52 +00:00
|
|
|
name: 'justify', items: [
|
|
|
|
"JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock"
|
2013-08-09 13:23:16 +00:00
|
|
|
]},{
|
2013-08-09 13:13:52 +00:00
|
|
|
name: 'special', items: [
|
|
|
|
"Image", "Table"
|
2013-08-09 13:23:16 +00:00
|
|
|
]},{
|
2013-08-09 13:13:52 +00:00
|
|
|
name: 'styles', items: [
|
|
|
|
"Format", "Styles"
|
2013-08-07 11:59:05 +00:00
|
|
|
]}
|
2013-08-07 12:17:46 +00:00
|
|
|
],
|
|
|
|
// styles dropdown in toolbar
|
|
|
|
stylesSet: [
|
|
|
|
// emphasis
|
|
|
|
{name: "Muted", element: 'span', attributes: {'class': 'text-muted'}},
|
|
|
|
{name: "Primary", element: 'span', attributes: {'class': 'text-primary'}},
|
|
|
|
{name: "Warning", element: 'span', attributes: {'class': 'text-warning'}},
|
|
|
|
{name: "Danger", element: 'span', attributes: {'class': 'text-danger'}},
|
|
|
|
{name: "Success", element: 'span', attributes: {'class': 'text-success'}},
|
|
|
|
{name: "Info", element: 'span', attributes: {'class': 'text-info'}}
|
|
|
|
],
|
2013-07-25 14:55:05 +00:00
|
|
|
};
|
|
|
|
},
|
2013-07-30 14:36:43 +00:00
|
|
|
// TODO clean
|
|
|
|
snippet_carousel: function () {
|
|
|
|
var self = this;
|
2013-07-31 15:05:11 +00:00
|
|
|
$('.carousel .js_carousel_options .label').on('click', function (e) {
|
|
|
|
e.preventDefault();
|
2013-08-12 10:55:21 +00:00
|
|
|
var $button = $(e.currentTarget);
|
2013-07-31 15:05:11 +00:00
|
|
|
var $c = $button.parents(".carousel:first");
|
|
|
|
|
|
|
|
if($button.hasClass("js_add")) {
|
|
|
|
var cycle = $c.find(".carousel-inner .item").size();
|
|
|
|
$c.find(".carousel-inner").append(QWeb.render("Website.Snipped.carousel"));
|
|
|
|
$c.carousel(cycle);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var cycle = $c.find(".carousel-inner .item.active").remove();
|
|
|
|
$c.find(".carousel-inner .item:first").addClass("active");
|
|
|
|
$c.carousel(0);
|
|
|
|
self.trigger('change', self, null);
|
|
|
|
}
|
2013-07-30 14:36:43 +00:00
|
|
|
});
|
2013-07-31 15:05:11 +00:00
|
|
|
$('.carousel .js_carousel_options').show();
|
2013-07-30 14:36:43 +00:00
|
|
|
}
|
2013-07-25 14:55:05 +00:00
|
|
|
});
|
|
|
|
|
2013-08-19 09:25:07 +00:00
|
|
|
instance.website.Snippets = instance.web.Widget.extend({
|
|
|
|
template: 'website.snippets',
|
|
|
|
init: function () {
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
},
|
|
|
|
start: function() {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: "/page/website.snippets",
|
|
|
|
dataType: "text",
|
|
|
|
success: function(text){
|
|
|
|
self.$el.html(text);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// load snippets
|
|
|
|
// /page/website.snippets
|
|
|
|
},
|
|
|
|
setup_droppable: function () {
|
|
|
|
var self = this;
|
|
|
|
$('.oe_snippet_drop').remove();
|
|
|
|
var droppable = '<div class="oe_snippet_drop"></div>';
|
|
|
|
var $zone = $(':not(.oe_snippet) > .container');
|
|
|
|
$zone.after(droppable);//.after(droppable);
|
|
|
|
|
|
|
|
$(".oe_snippet_drop").droppable({
|
|
|
|
hoverClass: 'oe_accepting',
|
|
|
|
drop: function( event, ui ) {
|
|
|
|
console.log(event, ui, "DROP");
|
|
|
|
|
|
|
|
$(event.target).replaceWith($(ui.draggable).html());
|
|
|
|
$('.oe_selected').remove();
|
|
|
|
$('.oe_snippet_drop').remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
toggle: function(){
|
|
|
|
if(this.$el.hasClass('oe_hidden')){
|
|
|
|
this.$el.removeClass('oe_hidden');
|
|
|
|
}else{
|
|
|
|
this.$el.addClass('oe_hidden');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
snippet_start: function () {
|
|
|
|
var self = this;
|
|
|
|
$('.oe_snippet').draggable().click(function(ev) {
|
|
|
|
self.setup_droppable();
|
|
|
|
$(".oe_snippet_drop").show();
|
|
|
|
$('.oe_selected').removeClass('oe_selected');
|
|
|
|
$(ev.currentTarget).addClass('oe_selected');
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2013-07-02 18:51:06 +00:00
|
|
|
$(function(){
|
|
|
|
|
2013-07-02 21:00:35 +00:00
|
|
|
function make_static(){
|
|
|
|
$('.oe_snippet_demo').removeClass('oe_new');
|
2013-07-24 10:08:13 +00:00
|
|
|
$('.oe_page *').off('mouseover mouseleave');
|
2013-07-02 21:00:35 +00:00
|
|
|
$('.oe_page .oe_selected').removeClass('oe_selected');
|
|
|
|
}
|
|
|
|
|
2013-07-02 18:51:06 +00:00
|
|
|
var selected_snippet = null;
|
|
|
|
function snippet_click(event){
|
|
|
|
if(selected_snippet){
|
|
|
|
selected_snippet.removeClass('oe_selected');
|
|
|
|
if(selected_snippet[0] === $(this)[0]){
|
|
|
|
selected_snippet = null;
|
|
|
|
event.preventDefault();
|
|
|
|
make_static();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$(this).addClass('oe_selected');
|
|
|
|
selected_snippet = $(this);
|
|
|
|
make_editable();
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2013-07-02 19:45:40 +00:00
|
|
|
//$('.oe_snippet').click(snippet_click);
|
2013-07-02 18:51:06 +00:00
|
|
|
|
|
|
|
var hover_element = null;
|
|
|
|
|
|
|
|
function make_editable( constraint_after, constraint_inside ){
|
|
|
|
if(selected_snippet && selected_snippet.hasClass('oe_new')){
|
|
|
|
$('.oe_snippet_demo').addClass('oe_new');
|
|
|
|
}else{
|
|
|
|
$('.oe_snippet_demo').removeClass('oe_new');
|
|
|
|
}
|
|
|
|
|
|
|
|
$('.oe_page *').off('mouseover');
|
|
|
|
$('.oe_page *').off('mouseleave');
|
|
|
|
$('.oe_page *').mouseover(function(event){
|
|
|
|
console.log('hover:',this);
|
|
|
|
if(hover_element){
|
|
|
|
hover_element.removeClass('oe_selected');
|
|
|
|
hover_element.off('click');
|
|
|
|
}
|
|
|
|
$(this).addClass('oe_selected');
|
|
|
|
$(this).click(append_snippet);
|
|
|
|
hover_element = $(this);
|
|
|
|
event.stopPropagation();
|
|
|
|
});
|
|
|
|
$('.oe_page *').mouseleave(function(){
|
|
|
|
if(hover_element && $(this) === hover_element){
|
|
|
|
hover_element = null;
|
|
|
|
$(this).removeClass('oe_selected');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-08-11 14:06:19 +00:00
|
|
|
function customier_option_get(event){
|
|
|
|
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
|
2013-07-02 18:51:06 +00:00
|
|
|
function append_snippet(event){
|
|
|
|
console.log('click',this,event.button);
|
|
|
|
if(event.button === 0){
|
|
|
|
if(selected_snippet){
|
|
|
|
if(selected_snippet.hasClass('oe_new')){
|
|
|
|
var new_snippet = $("<div class='oe_snippet'></div>");
|
|
|
|
new_snippet.append($(this).clone());
|
|
|
|
new_snippet.click(snippet_click);
|
|
|
|
$('.oe_snippet.oe_selected').before(new_snippet);
|
|
|
|
}else{
|
|
|
|
$(this).after($('.oe_snippet.oe_selected').contents().clone());
|
|
|
|
}
|
|
|
|
selected_snippet.removeClass('oe_selected');
|
|
|
|
selected_snippet = null;
|
|
|
|
make_static();
|
|
|
|
}
|
|
|
|
}else if(event.button === 1){
|
|
|
|
$(this).remove();
|
|
|
|
}
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-08-14 08:34:39 +00:00
|
|
|
$(function () {
|
|
|
|
$(document).on('click', '.js_publish, .js_unpublish', function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var $link = $(this).parent();
|
|
|
|
$link.find('.js_publish, .js_unpublish').addClass("hidden");
|
|
|
|
var $unp = $link.find(".js_unpublish");
|
|
|
|
var $p = $link.find(".js_publish");
|
2013-08-14 08:45:05 +00:00
|
|
|
$.post('/website/publish', {'id': $link.data('id'), 'object': $link.data('object')}, function (result) {
|
2013-08-14 08:34:39 +00:00
|
|
|
if (+result) {
|
|
|
|
$p.addClass("hidden");
|
|
|
|
$unp.removeClass("hidden");
|
|
|
|
} else {
|
|
|
|
$p.removeClass("hidden");
|
|
|
|
$unp.addClass("hidden");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-07-24 10:08:13 +00:00
|
|
|
};
|