1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00
movim_ynh/sources/app/widgets/Publish/publish.js
2015-12-21 22:59:03 +01:00

80 lines
2.2 KiB
JavaScript

var Publish = {
init: function() {
if(localStorage.getItem('share_url')) {
Publish_ajaxCreateBlog();
MovimTpl.showPanel();
}
},
setEmbed: function() {
if(localStorage.getItem('share_url')) {
var embed = document.querySelector('input[name=embed]');
embed.value = localStorage.getItem('share_url');
embed.onpaste();
localStorage.removeItem('share_url');
}
},
enableSend: function() {
movim_remove_class('#button_send', 'disabled');
},
disableSend: function() {
movim_add_class('#button_send', 'disabled');
},
enableContent: function() {
document.querySelector('#enable_content').style.display = 'none';
document.querySelector('#content_field').style.display = 'block';
},
headerBack: function(server, node, ok) {
// We check if the form is filled
if(Publish.checkFilled() && ok == false) {
Publish_ajaxFormFilled(server, node);
return;
}
// We are on the news page
if(typeof Post_ajaxClear === 'function') {
Post_ajaxClear();
//Header_ajaxReset('news');
MovimTpl.hidePanel();
} else {
Group_ajaxGetItems(server, node);
Group_ajaxGetAffiliations(server, node);
}
},
checkFilled: function() {
var form = document.querySelector('form[name=post]');
var i = 0;
while(i < form.elements.length)
{
if(form.elements[i].type != 'hidden'
&& form.elements[i].value != form.elements[i].defaultValue) {
return true;
}
i++;
}
return false;
},
initEdit: function() {
Publish.enableContent();
Publish_ajaxEmbedTest(document.querySelector('#content_link input').value);
movim_textarea_autoheight(document.querySelector('#content_field textarea'));
}
}
Upload.attach(function() {
var embed = document.querySelector('input[name=embed]');
embed.value = Upload.get;
embed.onpaste();
});
MovimWebsocket.attach(function() {
Publish.init();
});