function get_part_id(){ return $(".edit_page_part,.edit_page").attr("action").split('/').pop(); } function get_object_path(){ a = window.location.href.split('/'); a.pop(); return a.join('/'); } $("div.editable").live("mouseenter mouseleave", function (event) { $(this).children('.edit_link').toggle(); }); $("#page_design").live('change', function() { $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_themes'); }); // $("#page_module_app_id").live('change', function() { // var app_id = $(this).val(); // if(app_id!=''){ // $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_after_module_changed',function(data, textStatus){ // if(textStatus == 'success'){ // $(this).after(data); // } // }); // } // else{ // $("#app_page_url").children().remove(); // } // }); $("#module_app_list select").live('change', function() { $.getScript(get_object_path() + '/reload_after_module_changed?module_app_id='+$(this).val()); //?part_id=' + get_part_id()); }); $("#widget_list select,#frontend_list select").live('change', function() { $.getScript(get_object_path() +'/reload_after_list_changed?frontend=' + $(this).val() + '&module_app_id=' + $("#module_app_list select").val() );//+ '&part_id=' + get_part_id()); }); $("#tag_list select").live('change', function() { $.getScript($(this).attr('rel') + '?type=' + $(this).val()); }); $("select.widget_field_select").live('change', function() { $.getScript(get_object_path() + '/reload_after_widget_field_changed?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')+ '&module_app_id=' +$("#page_module_app_id,page_part_module_app_id").val()); }); $('.part_kind').live('click', function() { $('.part_kind_partial').hide(); $('#part_' + $(this).attr('value')).show(); }); $(document).ready(function(){ bindTreeDragHandle(); }); var bindTreeDragHandle = function(){ $('ol.sortable').nestedSortable({ disableNesting: 'no-nest', forcePlaceholderSize: true, handle: 'i', helper: 'clone', items: 'li', maxLevels: 3, opacity: .5, placeholder: 'placeholder', revert: 250, tabSize: 25, tolerance: 'pointer', toleranceElement: '> div', stop: function(event, ui) { $.post("<%= Rails.application.routes.url_helpers.admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } ); } }); }