/*
 *  (c) 2000-2014 deviantART, Inc. All rights reserved.
 */
DWait.ready(["jms/lib/jquery/plugins/jquery.somedata.js","jms/lib/gmi.js","jms/lib/Base.js","jms/lib/pubsub.js","jms/lib/jquery/jquery.current.js","jms/lib/ddt.js","jms/pages/duperbrowse/stream/base.custom.stream.js"],function(){(function(e,t){t.JournalStream=DuperbrowseBaseCustomStream.extend({init_stream:function(){var t=e("div.journal-wrapper.tt-a",this.$),r=this;e.each(t,function(t,s){var a=e("div.journal-footer a.more",s),i=e(s),o=a.data("deviationid"),n=a.attr("href");r._add_item(i,i,t,o,n),ddt.log("Duperbrowse","journal stream bind",a,e("div.gr-top h2 a",s)),a.on("click",r._open_duperbrowse.bind(r)),e("div.gr-top h2 a",s).on("click",r._open_duperbrowse.bind(r))})},_get_item_data_from_clicked_element:function(t){var r=t.closest(".tt-a"),s=r.someData("itemid","stream_offset");return e.isEmptyObject(s)?!1:s},_on_stream_item_closed:function(r){var s=e(" > div.journal-wrapper.tt-a",this.$).filter(function(){return e.data(this,"itemid")==r.current_id});if(0!==s.length){var a=s.offset().top,i=e(t).scrollTop();a>i&&i+e(t).height()>a||e(t).scrollTop(a)}}})})(jQuery,window),window.DWait&&DWait.run("jms/pages/grusers/journal/journal.stream.js")});
DWait.ready(["jms/lib/difi.js","jms/pages/gruzecontrol/gmframe_gruser.js","jms/pages/grusers/journal/journal.stream.js","jms/lib/popup2.js","jms/lib/jquery/jquery.current.js"],function(){(function(){function t(){$(":gmi(JournalStream)").gmi();var t=GMI.query("GMFrame_Gruser",{match:{typeid:10}})[0];jQuery(t.gmi_node).find("div.gm-controls").first().append('<b class="gm-chaos gm-chaos-new gmbuttons"><a title="Submit" href="/blog/#new" class="gmbutton2 gmbutton2chaos">New</a></b>')}function e(t){$(":gmi(JournalStream)").gmi();var e=function(t,e,i){return i=i||"c",$('<td style="padding:0 8px"></td>').append($('<a href="#" class="gmbutton2 gmbutton2'+i+'">'+t+"<b></b></a>").click(function(t){t.preventDefault(),e.call(this,t)}))},i=$("#blog"+t),n=i.siblings("div.gm-controls");0==n.length&&(n=i.parent().siblings("div.gm-controls"));var o='<div class="gm-controls" style="width: auto"><b class="gm-chaos gm-chaos-edit gmbuttons"><a href="#" class="gmbutton2 gmbutton2chaos">Edit</a></b></div>',r=function(){var t=$(this),n=/blog-(\d+)/.exec(t.attr("id"));if(n){var r=n[1],a=function(n){n&&n.preventDefault(),Popup2.hideAll();var o=GMI.up(this);t.parent().find("div.gm-controls").first().hide(),o.disableTransitions(),o.pretendView(!0),o.justSave(function(i,n){if(o.pretendView(!1),!i)return alert("Edit failed."),void 0;var r,a,s;r=$(n.response.content.html),s=function(){a=$('<div class="gr-hijack c pp"><table class="f" align="center"><tr></tr></table></div>').find("tr").append(e("Save",function(){o.pretendView(!0),o.justSave(function(t,e){if(o.pretendView(!1),!t)return alert("Saving failed"),void 0;if("submit"==e.response.content.view){var i=r;return r=$(e.response.content.html),i.replaceWith(r),s(),o.importGWebPage(e.response.content),void 0}window.location=window.location.href.replace("?edit","")},r.find(".gr-body").get(0),!1,"submit")},"s")).append(e("Cancel",function(){r.remove(),t.show(),t.parent().find("div.gm-controls").first().show()})).end().appendTo(r.find(".gr-body"))},s(),t.hide().after(r),o.importGWebPage(n.response.content)},i.get(0),{deviationid:r},"load_edit"),t.blur()},s=$(o).insertBefore(t);s.find("a").click(function(t){t.preventDefault(),GMI.gmiUp(this).configClick(this,function(t){var e=$(t).find(".blockmenu");e.find("a.edit_link").css("font-weight",""),e.find("div.blockdisabled").remove(),$('<a class="f" href="#" style="font-weight:bold">Edit this Journal Entry</a>').click(a).prependTo(e)})}),s.show().children().show(),t.data("blog-edit",a)}},a=GMI.query("GMFrame_Gruser",{match:{typeid:62}})[0],s=i.find("div.blogcontrol.editable");s.length>0&&($(a.gmi_node).find("div.gm-controls").first().remove(),s.each(r),$(a.gmi_node).find("div.gm-controls").first().append('<b class="gm-chaos gm-chaos-new gmbuttons"><a title="Submit" href="#" class="gmbutton2 gmbutton2chaos" onclick="return DWait.readyLink(\'jms/pages/gruzecontrol/gmframe_gruser.js\', this, function () { GMI.query(\'GMFrame_Gruser\', {match: {typeid: 62 }})[0].loadView(\'submit\') } )">New</a></b>'));var d=window.location.hash;if(d=d.replace("#",""),"new"==d)GMI.query("GMFrame_Gruser",{match:{typeid:62}})[0].loadView("submit");else if(i.find("div.blogcontrol.editnow")){var l=i.find("div.blogcontrol.editnow").data("blog-edit");l&&l.call(i.find("div.blogcontrol.editnow")[0])}}DWait.init("BlogModule.init",function(t){e($(t).data("module-id"))}),DWait.init("BlogModule.init_wrapped",function(){t()})})(),window.DWait&&DWait.run("jms/pages/gruzecontrol/widgets/module_blog.js")});if(window.DWait){DWait.count()}