global.$ = global.jQuery = require('jquery');

require('semantic-ui-css');

$(document).ready(function () {
    $('.ui.sticky')
        .sticky({
            context: '#main'
        })
    ;

    $("a.close.idea").click(function (action) {
        var slug = $(this).data('slug');
        $.post(Routing.generate('idea_close', {slug: slug}), {});

        location.reload()
    });
    $("a.open.idea").click(function (action) {
        var slug = $(this).data('slug');
        $.post(Routing.generate('idea_open', {slug: slug}), {});

        location.reload()
    });
    $("a.approve.idea").click(function (action) {
        var slug = $(this).data('slug');
        $.post(Routing.generate('idea_approve', {slug: slug}), {});

        location.reload()
    });
    $("a.reject.idea").click(function (action) {
        var slug = $(this).data('slug');
        $.post(Routing.generate('idea_reject', {slug: slug}), {});

        location.reload()
    });
    $("a.join.idea").click(function (action) {
        var slug = $(this).data('slug');
        $.post(Routing.generate('idea_join', {slug: slug}), {});

        location.reload()
    });
    $("a.leave.idea").click(function (action) {
        var slug = $(this).data('slug');
        $.post(Routing.generate('idea_leave', {slug: slug}), {});

        location.reload()
    });

    // fix menu when passed
    $('.masthead')
        .visibility({
            once: false,
            onBottomPassed: function() {
                $('.fixed.menu').transition('fade in');
            },
            onBottomPassedReverse: function() {
                $('.fixed.menu').transition('fade out');
            }
        })
    ;

    // create sidebar and attach to menu open
    $('.ui.sidebar')
        .sidebar('attach events', '.toc.item')
    ;
});

@@ -331,35 +331,73 @@
 lug: slug%7D), %7B%7D)
-;%0A%0A
+%0A            .done(function () %7B%0A        
         location
@@ -397,32 +397,49 @@
 ocation.reload()
+;%0A            %7D);
 %0A    %7D);%0A    $(%22
@@ -574,35 +574,73 @@
 lug: slug%7D), %7B%7D)
-;%0A%0A
+%0A            .done(function () %7B%0A        
         location
@@ -640,32 +640,49 @@
 ocation.reload()
+;%0A            %7D);
 %0A    %7D);%0A    $(%22
@@ -827,35 +827,69 @@
  slug%7D), %7B%7D)
-;%0A%0A
+%0A            .done(function () %7B%0A    
         
 location.rel
@@ -868,32 +868,36 @@
 ) %7B%0A            
+    
 location.reload(
@@ -889,32 +889,49 @@
 ocation.reload()
+;%0A            %7D);
 %0A    %7D);%0A    $(%22
@@ -1070,35 +1070,73 @@
 lug: slug%7D), %7B%7D)
-;%0A%0A
+%0A            .done(function () %7B%0A        
         location
@@ -1136,32 +1136,49 @@
 ocation.reload()
+;%0A            %7D);
 %0A    %7D);%0A    $(%22
@@ -1313,35 +1313,73 @@
 lug: slug%7D), %7B%7D)
-;%0A%0A
+%0A            .done(function () %7B%0A        
         location
@@ -1379,32 +1379,49 @@
 ocation.reload()
+;%0A            %7D);
 %0A    %7D);%0A    $(%22
@@ -1566,19 +1566,57 @@
 g%7D), %7B%7D)
-;%0A%0A
+%0A            .done(function () %7B%0A        
         
@@ -1632,16 +1632,33 @@
 reload()
+;%0A            %7D);
 %0A    %7D);

Fix POST responses