$.CMS = function(){ var current_path = window.location.pathname; var admin_path_prefix = current_path.split('/')[1] $(function(){ $.CMS.slugify(); $.CMS.tree_methods(); $.CMS.load_page_blocks(); $.CMS.enable_rich_text(); $.CMS.enable_codemirror(); $.CMS.enable_date_picker(); $.CMS.enable_desc_toggle(); $.CMS.enable_sortable_list(); if($('form.new_cms_page, form.edit_cms_page').get(0)) $.CMS.enable_page_save_form(); if($('#page_save').get(0)) $.CMS.enable_page_save_widget(); if($('#uploader_button').get(0)) $.CMS.enable_uploader(); }); return { enable_sortable_list: function(){ $('ul.sortable, ul.sortable ul').sortable({ handle: 'div.dragger', axis: 'y', update: function(){ $.post(current_path + '/reorder', '_method=put&'+$(this).sortable('serialize')); } }) }, slugify: function(){ $('input#slugify').bind('keyup.cms', function() { var slug_input = $('input#slug'); var delimiter = slug_input.hasClass('delimiter-underscore') ? '_' : '-'; slug_input.val( slugify( $(this).val(), delimiter ) ); }); function slugify(str, delimiter){ var opposite_delimiter = (delimiter == '-') ? '_' : '-'; str = str.replace(/^\s+|\s+$/g, ''); var from = "ÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛàáäâèéëêìíïîòóöôùúüûÑñÇç"; var to = "aaaaeeeeiiiioooouuuuaaaaeeeeiiiioooouuuunncc"; for (var i=0, l=from.length ; i' + file.name + '' ); }); uploader.start(); }); uploader.bind('Error', function(up, err) { alert('File Upload failed') }); uploader.bind('FileUploaded', function(up, file, response){ $('#' + file.id).replaceWith(response.response); }); } } }();