/* Minified: jquery.notebookPageVersions.js, jquery.reorderNotebookPages.js */
(function($){var methods={init:function(s){var settings=jQuery.extend({compare_versions_url:"#",revert_to_version_url:"#",can_manage:false,versions:null},s);return this.each(function(){var wrapper=$(this);var render_versions=function(versions){App.widgets.TextCompareDialog.reset();var table=wrapper.find("table.notebook_versions_table");if(table.length){table.find("tbody").empty()}else{table=$('<table class="notebook_versions_table common auto"><tbody></tbody></table>').appendTo(wrapper)}if(jQuery.isArray(versions)&&versions.length){$.each(versions,function(i,version){App.widgets.TextCompareDialog.addVersion({version:version.version,name:version.name,body:version.body});var row=$('<tr class="notebook_page_version"><td class="name">'+App.lang('<a href=":url" class="compare_versions" left_version_num=":left_version_num" right_version_num=":right_version_num">#:version</a> by :user (on :date)',{url:settings.compare_versions_url,version:version.version,user:version.created_by["display_name"],date:version.created_on["formatted_date_gmt"],left_version_num:settings.object["revision_num"],right_version_num:version.version})+'</td><td class="options"></td></tr>').appendTo(table.find("tbody"));row.find("a.compare_versions").click(function(){App.widgets.TextCompareDialog.compareVersions(this);return false});var options_cell=row.find("td.options");if(settings.can_manage){$('<a href="'+settings.revert_to_version_url.replace("--REVERT-TO-VERSION--",version.version).clean()+'"><img src="'+App.Wireframe.Utils.imageUrl("icons/12x12/swap.png","environment",App.Wireframe.Utils.INTERFACE_DEFAULT)+'"></a>').appendTo(options_cell).asyncLink({confirmation:App.lang("Are you sure that you want to revert to selected version?"),success_event:"notebook_page_updated",success_message:App.lang("Page content successfully reverted to version #:version_num",{version_num:version.version})});if(version.urls&&version.urls["delete"]){$('<a href="'+version.urls["delete"].clean()+'"><img src="'+App.Wireframe.Utils.imageUrl("icons/12x12/delete.png","environment",App.Wireframe.Utils.INTERFACE_DEFAULT)+'"></a>').appendTo(options_cell).asyncLink({confirmation:App.lang("Are you sure that you want to delete selected version?"),success_event:"notebook_page_version_deleted",success:function(){App.Wireframe.Flash.success("Selected page version has been removed");$(this).parent().parent().remove()},error:function(r){App.Wireframe.Flash.error("Failed to remove selected page version")}})}}});App.widgets.TextCompareDialog.addVersion({version:settings.object["revision_num"],name:settings.object["name"],body:settings.object["body_formatted"]})}var row=$('<tr class="notebook_page_version"><td class="name">'+App.lang("<span>#:version</span> by :user (on :date)",{version:settings.object["revision_num"],user:settings.object["updated_by"]["short_display_name"],date:settings.object["updated_on"]["formatted_date_gmt"],})+'</td><td class="options"><span class="pill">'+App.lang("Latest")+"</span></td></tr>").prependTo(table.find("tbody"))};render_versions(settings.revisions);if(settings.object.listen){App.Wireframe.Events.bind(settings.object.listen+".single",function(event,updated_object){if(updated_object.id==settings.object.id&&updated_object["class"]==settings.object["class"]){settings.object=updated_object;render_versions(updated_object.revisions)}})}})}};$.fn.notebookPageVersions=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof method==="object"||!method){return methods.init.apply(this,arguments)}else{throw"Method "+method+" does not exist on jQuery.notebookPageVersions"}}}})(jQuery);
(function($){var methods={init:function(s){var settings=jQuery.extend({},s);return this.each(function(){var wrapper=$(this);wrapper.find(">ul ul").sortable({connectWith:"#"+wrapper.attr("id")+" ul",items:"li",forcePlaceholderSize:true,placeholder:"drop_target"});var form=wrapper.parents("form:first");var data=null;form.submit(function(){if(data){data.remove();data=null}data=$('<div class="data"></div>').appendTo(form);wrapper.find("span").each(function(){var item=$(this);var parent=item.parent().parents("li:first").find(">span:first");if(parent.length){data.append('<input type="hidden" name="reorder['+item.attr("object_id")+'][parent_id]" value="'+parent.attr("object_id")+'" />');data.append('<input type="hidden" name="reorder['+item.attr("object_id")+'][parent_type]" value="'+parent.attr("object_type")+'" />')}});return false})})}};$.fn.reorderNotebookPages=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof method==="object"||!method){return methods.init.apply(this,arguments)}else{throw"Method "+method+" does not exist on jQuery.reorderNotebookPages"}}}})(jQuery);
