Sha256: ffbcd2cf237bb1ea24db6ff8db5ef9208ff0c091f998a383a76bb40e001f40a6

Contents?: true

Size: 1.81 KB

Versions: 19

Compression:

Stored size: 1.81 KB

Contents

function save_page() {
	tinyMCE.triggerSave(true,true);
	var form = jQuery('#editor-form');
	jQuery.post(form.attr('action') + '.js', form.serialize(),
	  function(data){
			var result = eval('(' + data + ')');
			show_message(result['message']);
			if('true' == result['success']){
				undirty();
				update_permalink(result['url_key']);
			}			
	  });
	return false;
}

function show_message(message){
	jQuery.jGrowl.info(message);
}

function undirty(){
	var ed = tinyMCE.get('mce-content');
	ed.isNotDirty = 1;
}

// The following are use to manage the permalink on a given page
jQuery(document).ready(function() {
		
	jQuery('#permalink-edit').click(function() {
		jQuery('#finish-permalink-buttons').show();
		jQuery('#edit-permalink').show();
		jQuery('#view-permalink').hide();
		jQuery('#edit-permalink-buttons').hide();
		return false;
	});
	
	jQuery('#permalink-save').click(function() {
		hide_edit();
		save_permalink();
		return false;
	});
	
	jQuery('#permalink-cancel').click(function() {
		hide_edit();
		jQuery("#url-key").val(jQuery('#view-permalink').html());
		return false;
	});
});

function hide_edit(){
	jQuery('#finish-permalink-buttons').hide();
	jQuery('#view-permalink').show();
	jQuery('#edit-permalink-buttons').show();
	jQuery('#edit-permalink').hide();
}

function save_permalink() {
  var form = jQuery('#editor-form');
	jQuery.post(form.attr('action') + '.js', {url_key: jQuery('#url-key').val(), action: 'update', _method: 'put', only_permalink: 'true' },
	  function(data){
			var result = eval('(' + data + ')');
			show_message(result['message']);
			if('true' == result['success']){
				update_permalink(result['url_key']);
			}			
	  });
	return false;
}

function update_permalink(url){
	jQuery("#preview-page").attr('href', '/pages/' + url )
	jQuery("#view-permalink").html(url);
	jQuery("#url-key").val(url);
}

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
muck-contents-0.1.11 public/javascripts/tiny_mce_helper.js
muck-contents-0.1.10 public/javascripts/tiny_mce_helper.js
muck-contents-0.1.9 public/javascripts/tiny_mce_helper.js
muck-contents-0.1.8 public/javascripts/tiny_mce_helper.js
muck-blogs-0.1.7 test/rails_root/public/javascripts/tiny_mce_helper.js
muck-contents-0.1.7 public/javascripts/tiny_mce_helper.js
muck-blogs-0.1.6 test/rails_root/public/javascripts/tiny_mce_helper.js
muck-contents-0.1.6 public/javascripts/tiny_mce_helper.js
muck-contents-0.1.5 public/javascripts/tiny_mce_helper.js
muck-blogs-0.1.5 test/rails_root/public/javascripts/tiny_mce_helper.js
muck-contents-0.1.4 public/javascripts/tiny_mce_helper.js
muck-blogs-0.1.4 test/rails_root/public/javascripts/tiny_mce_helper.js
muck-contents-0.1.1 public/javascripts/tiny_mce_helper.js
muck-contents-0.1.2 public/javascripts/tiny_mce_helper.js
muck-contents-0.1.3 public/javascripts/tiny_mce_helper.js
muck-blogs-0.1.1 test/rails_root/public/javascripts/tiny_mce_helper.js
muck-blogs-0.1.2 test/rails_root/public/javascripts/tiny_mce_helper.js
muck-blogs-0.1.3 test/rails_root/public/javascripts/tiny_mce_helper.js
muck-blogs-0.1.0 test/rails_root/public/javascripts/tiny_mce_helper.js