Created
July 29, 2015 17:42
-
-
Save gcphost/a0ab6c7586931d0fb8b5 to your computer and use it in GitHub Desktop.
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
<link rel="stylesheet" property="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css"> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script> | |
<script> | |
$("#category").select2({ | |
tags: true, placeholder :'Categories', width: '100%' | |
}); | |
$("#tags").select2({ | |
tags: true, placeholder :'Tags', width: '100%' | |
}); | |
$('.layout-picker').on('click', function(){ | |
$('.layout-picker').removeClass('active'); | |
$(this).addClass('active'); | |
$('#template').val($(this).data('tpl')); | |
}); | |
</script> | |
<script src="/js/plugins/ckeditor/ckeditor.js"></script> | |
<script> | |
CKEDITOR.plugins.addExternal('imageupload', '/js/plugins/ckeditor/plugins/imageupload/', 'plugin.js'); | |
var editor = CKEDITOR.inline('bodyi', { | |
extraPlugins: 'imageupload,codesnippet,sourcedialog', | |
toolbar: [ | |
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: ['Templates', 'Paste', 'PasteText', 'Scayt' ] }, | |
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl' ] }, | |
{ name: 'insert', items: [ 'Image', 'Flash', 'Table' ] }, | |
{ name: 'colors', items: [ 'TextColor', 'BGColor', '-','ShowBlocks' ] }, | |
'/', | |
{ name: 'links', items: [ 'Link', 'Unlink' ] }, | |
{ name: 'others', items: [ 'Source', 'Imageupload', 'CodeSnippet', 'SourceDialog' ] }, | |
{ name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] }, | |
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', '-', 'RemoveFormat', '-', 'HorizontalRule' ] }, | |
], | |
on: { | |
instanceReady: function() { | |
periodicData(); | |
} | |
} | |
}); | |
var periodicData = ( function(){ | |
var data, oldData; | |
return function() { | |
if ( ( data = editor.getData() ) !== oldData ) { | |
oldData = data; | |
$('#body').val(data); | |
} | |
setTimeout( periodicData, 1000 ); | |
}; | |
})(); | |
</script> | |
<script> | |
$('#form').postJson(function( data ) { | |
if(data.success){ | |
window.location=data.success | |
}else if(data.failed){ | |
alert('Sorry, something was wrong: ' + data.failed); | |
} else alert('Sorry, something went very wrong: ' + data); | |
}); | |
</script> |
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
$.fn.postJson = function(success) { | |
return this.each(function() { | |
$(this).on('submit', function(){ | |
$.post( $(this).data('action'), $(this).serialize(), success, "json"); | |
return false; | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment