|
|
@@ -1,11 +1,15 @@
|
|
|
/* jshint browser: true, jquery: true */
|
|
|
-/* global FB, marked */
|
|
|
/* Author: Sotaro KARASAWA <sotarok@crocos.co.jp>
|
|
|
*/
|
|
|
|
|
|
var hljs = require('highlight.js');
|
|
|
var jsdiff = require('diff');
|
|
|
var marked = require('marked');
|
|
|
+var io = require('socket.io-client');
|
|
|
+
|
|
|
+require('bootstrap-sass');
|
|
|
+require('jquery.cookie');
|
|
|
+
|
|
|
var Crowi = {};
|
|
|
|
|
|
if (!window) {
|
|
|
@@ -219,21 +223,21 @@ Crowi.userPicture = function (user) {
|
|
|
};
|
|
|
|
|
|
|
|
|
-CrowiSearcher = function(path, $el) {
|
|
|
- this.$el = $el;
|
|
|
- this.path = path;
|
|
|
- this.searchResult = {};
|
|
|
-};
|
|
|
-CrowiSearcher.prototype.querySearch = function(keyword, option) {
|
|
|
-};
|
|
|
-CrowiSearcher.prototype.search = function(keyword) {
|
|
|
- var option = {};
|
|
|
- this.querySearch(keyword, option);
|
|
|
- this.$el.html(this.render());
|
|
|
-};
|
|
|
-CrowiSearcher.prototype.render = function() {
|
|
|
- return $('<div>');
|
|
|
-};
|
|
|
+//CrowiSearcher = function(path, $el) {
|
|
|
+// this.$el = $el;
|
|
|
+// this.path = path;
|
|
|
+// this.searchResult = {};
|
|
|
+//};
|
|
|
+//CrowiSearcher.prototype.querySearch = function(keyword, option) {
|
|
|
+//};
|
|
|
+//CrowiSearcher.prototype.search = function(keyword) {
|
|
|
+// var option = {};
|
|
|
+// this.querySearch(keyword, option);
|
|
|
+// this.$el.html(this.render());
|
|
|
+//};
|
|
|
+//CrowiSearcher.prototype.render = function() {
|
|
|
+// return $('<div>');
|
|
|
+//};
|
|
|
|
|
|
|
|
|
$(function() {
|
|
|
@@ -246,9 +250,25 @@ $(function() {
|
|
|
|
|
|
Crowi.linkPath();
|
|
|
|
|
|
+ $('[data-toggle="popover"]').popover();
|
|
|
$('[data-toggle="tooltip"]').tooltip();
|
|
|
$('[data-tooltip-stay]').tooltip('show');
|
|
|
|
|
|
+ $('#toggle-sidebar').click(function(e) {
|
|
|
+ var $mainContainer = $('.main-container');
|
|
|
+ if ($mainContainer.hasClass('aside-hidden')) {
|
|
|
+ $('.main-container').removeClass('aside-hidden');
|
|
|
+ $.cookie('aside-hidden', 0, { expires: 30, path: '/' });
|
|
|
+ } else {
|
|
|
+ $mainContainer.addClass('aside-hidden');
|
|
|
+ $.cookie('aside-hidden', 1, { expires: 30, path: '/' });
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+
|
|
|
+ if ($.cookie('aside-hidden') == 1) {
|
|
|
+ $('.main-container').addClass('aside-hidden');
|
|
|
+ }
|
|
|
|
|
|
$('.copy-link').on('click', function () {
|
|
|
$(this).select();
|
|
|
@@ -330,6 +350,88 @@ $(function() {
|
|
|
$link.html(path.replace(new RegExp(shortPath + '(/)?$'), '<strong>' + shortPath + '$1</strong>'));
|
|
|
});
|
|
|
|
|
|
+ // for list page
|
|
|
+ $('#view-timeline .timeline-body').each(function()
|
|
|
+ {
|
|
|
+ var id = $(this).attr('id');
|
|
|
+ var contentId = '#' + id + ' > script';
|
|
|
+ var revisionBody = '#' + id + ' .revision-body';
|
|
|
+ var revisionPath = '#' + id + ' .revision-path';
|
|
|
+ var renderer = new Crowi.renderer($(contentId).html(), $(revisionBody));
|
|
|
+ renderer.render();
|
|
|
+ });
|
|
|
+
|
|
|
+ // login
|
|
|
+ $('#register').on('click', function() {
|
|
|
+ $('#login-dialog').addClass('to-flip');
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ $('#login').on('click', function() {
|
|
|
+ $('#login-dialog').removeClass('to-flip');
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ $('#btn-login-facebook').click(function(e)
|
|
|
+ {
|
|
|
+ var afterLogin = function(response) {
|
|
|
+ if (response.status !== 'connected') {
|
|
|
+ $('#login-form-errors').html('<p class="alert alert-danger">Facebookでのログインに失敗しました。</p>');
|
|
|
+ } else {
|
|
|
+ location.href = '/login/facebook';
|
|
|
+ }
|
|
|
+ };
|
|
|
+ FB.getLoginStatus(function(response) {
|
|
|
+ if (response.status === 'connected') {
|
|
|
+ afterLogin(response);
|
|
|
+ } else {
|
|
|
+ FB.login(function(response) {
|
|
|
+ afterLogin(response);
|
|
|
+ }, {scope: 'email'});
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#register-form input[name="registerForm[username]"]').change(function(e) {
|
|
|
+ var username = $(this).val();
|
|
|
+ $('#input-group-username').removeClass('has-error');
|
|
|
+ $('#help-block-username').html("");
|
|
|
+
|
|
|
+ $.getJSON('/_api/check_username', {username: username}, function(json) {
|
|
|
+ if (!json.valid) {
|
|
|
+ $('#help-block-username').html('<i class="fa fa-warning"></i>このユーザーIDは利用できません。<br>');
|
|
|
+ $('#input-group-username').addClass('has-error');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#btn-register-facebook').click(function(e)
|
|
|
+ {
|
|
|
+ var afterLogin = function(response) {
|
|
|
+ if (response.status !== 'connected') {
|
|
|
+ $('#register-form-errors').html('<p class="alert alert-danger">Facebookでのログインに失敗しました。</p>');
|
|
|
+
|
|
|
+ } else {
|
|
|
+ var authR = response.authResponse;
|
|
|
+ $('#register-form input[name="registerForm[fbId]"]').val(authR.userID);
|
|
|
+ FB.api('/me?fields=name,username,email', function(res) {
|
|
|
+ $('#register-form input[name="registerForm[name]"]').val(res.name);
|
|
|
+ $('#register-form input[name="registerForm[username]"]').val(res.username || '');
|
|
|
+ $('#register-form input[name="registerForm[email]"]').val(res.email);
|
|
|
+
|
|
|
+ $('#register-form .facebook-info').remove();
|
|
|
+ $('#register-form').prepend('<div class="facebook-info"><img src="//graph.facebook.com/' + res.id + '/picture?size=square" width="25"> <i class="fa fa-facebook-square"></i> ' + res.name + 'さんとして登録します</div>');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ FB.getLoginStatus(function(response) {
|
|
|
+ if (response.status === 'connected') {
|
|
|
+ afterLogin(response);
|
|
|
+ } else {
|
|
|
+ FB.login(function(response) {
|
|
|
+ afterLogin(response);
|
|
|
+ }, {scope: 'email'});
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
if (pageId) {
|
|
|
|
|
|
@@ -444,7 +546,7 @@ $(function() {
|
|
|
|
|
|
// post comment event
|
|
|
$('#page-comment-form').on('submit', function() {
|
|
|
- $button = $('#commenf-form-button');
|
|
|
+ var $button = $('#comment-form-button');
|
|
|
$button.attr('disabled', 'disabled');
|
|
|
$.post('/_api/comments.add', $(this).serialize(), function(data) {
|
|
|
$button.removeAttr('disabled');
|
|
|
@@ -693,7 +795,40 @@ $(function() {
|
|
|
$(diffView).click();
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
+
|
|
|
+ // presentation
|
|
|
+ var presentaionInitialized = false
|
|
|
+ , $b = $('body');
|
|
|
+
|
|
|
+ $(document).on('click', '.toggle-presentation', function(e) {
|
|
|
+ var $a = $(this);
|
|
|
+
|
|
|
+ e.preventDefault();
|
|
|
+ $b.toggleClass('overlay-on');
|
|
|
+
|
|
|
+ if (!presentaionInitialized) {
|
|
|
+ presentaionInitialized = true;
|
|
|
+
|
|
|
+ $('<iframe />').attr({
|
|
|
+ src: $a.attr('href')
|
|
|
+ }).appendTo($('#presentation-container'));
|
|
|
+ }
|
|
|
+ }).on('click', '.fullscreen-layer', function() {
|
|
|
+ $b.toggleClass('overlay-on');
|
|
|
+ });
|
|
|
+
|
|
|
+ //
|
|
|
+ var me = $('body').data('me');
|
|
|
+ var socket = io();
|
|
|
+ socket.on('page edited', function (data) {
|
|
|
+ if (data.user._id != me
|
|
|
+ && data.page.path == pagePath) {
|
|
|
+ $('#notifPageEdited').show();
|
|
|
+ $('#notifPageEdited .edited-user').html(data.user.name);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } // end if pageId
|
|
|
|
|
|
// for search
|
|
|
+ //
|
|
|
});
|