-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
4,296 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#= require jquery | ||
#= require jquery_ujs | ||
#= require bootstrap | ||
#= require will_paginate | ||
#= require jquery.timeago | ||
#= require jquery.timeago.settings | ||
#= require jquery.hotkeys | ||
#= require jquery.chosen | ||
#= require jquery.autogrow-textarea | ||
#= require jquery.html5-fileupload | ||
#= require jquery-caret_pos | ||
#= require_self | ||
|
||
window.App = | ||
loading : () -> | ||
console.log "loading..." | ||
|
||
# 警告信息显示, to 显示在那个dom前(可以用 css selector) | ||
alert : (msg,to) -> | ||
$(to).before("<div data-alert class='alert-message'><a class='close' href='#'>X</a>#{msg}</div>") | ||
|
||
# 成功信息显示, to 显示在那个dom前(可以用 css selector) | ||
notice : (msg,to) -> | ||
$(to).before("<div data-alert class='alert-message success'><a class='close' href='#'>X</a>#{msg}</div>") | ||
|
||
openUrl : (url) -> | ||
window.open(url) | ||
|
||
|
||
|
||
|
||
|
||
|
||
$(document).ready -> | ||
$("abbr.timeago").timeago() | ||
$(".alert").alert() | ||
$('.dropdown-toggle').dropdown() | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,108 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ | ||
|
||
# PostsController 下所有页面的 JS 功能 | ||
window.Posts = | ||
# 往话题编辑器里面插入图片代码 | ||
appendImageFromUpload : (srcs) -> | ||
txtBox = $(".post_editor") | ||
caret_pos = txtBox.caretPos(); | ||
src_merged = "" | ||
for src in srcs | ||
src_merged = "\n" | ||
source = txtBox.val() | ||
before_text = source.slice(0, caret_pos) | ||
txtBox.val(before_text + src_merged + source.slice(caret_pos+1, source.count)) | ||
txtBox.caretPos(caret_pos+src_merged.length) | ||
txtBox.focus() | ||
|
||
# 上传图片 | ||
initUploader : () -> | ||
$("#post_add_image").bind "click", () -> | ||
$("#post_upload_images").click() | ||
return false | ||
|
||
opts = | ||
url : "/cpanel/photos" | ||
type : "POST" | ||
beforeSend : () -> | ||
$("#post_add_image").hide() | ||
$("#post_add_image").before("<span class='loading'>上传中...</span>") | ||
success : (result, status, xhr) -> | ||
$("#post_add_image").parent().find("span").remove() | ||
$("#post_add_image").show() | ||
|
||
Posts.appendImageFromUpload([result]) | ||
|
||
$("#post_upload_images").fileUpload opts | ||
return false | ||
|
||
|
||
|
||
preview: (body) -> | ||
$("#preview").text "Loading..." | ||
$.post "/cpanel/posts/preview", | ||
"body": body, | ||
(data) -> | ||
$("#preview").html data.body | ||
"json" | ||
|
||
hookPreview: (switcher, textarea) -> | ||
# put div#preview after textarea | ||
preview_box = $(document.createElement("div")).attr "id", "preview" | ||
preview_box.addClass("body") | ||
$(textarea).after preview_box | ||
preview_box.hide() | ||
|
||
$(".edit a",switcher).click -> | ||
$(".preview",switcher).removeClass("active") | ||
$(this).parent().addClass("active") | ||
$(preview_box).hide() | ||
$(textarea).show() | ||
false | ||
$(".preview a",switcher).click -> | ||
$(".edit",switcher).removeClass("active") | ||
$(this).parent().addClass("active") | ||
$(preview_box).show() | ||
$(textarea).hide() | ||
Posts.preview($(textarea).val()) | ||
false | ||
|
||
initCloseWarning: (el, msg) -> | ||
return false if el.length == 0 | ||
msg = "离开本页面将丢失未保存页面!" if !msg | ||
$("input[type=submit]").click -> | ||
$(window).unbind("beforeunload") | ||
el.change -> | ||
if el.val().length > 0 | ||
$(window).bind "beforeunload", (e) -> | ||
if $.browser.msie | ||
e.returnValue = msg | ||
else | ||
return msg | ||
else | ||
$(window).unbind("beforeunload") | ||
|
||
|
||
|
||
|
||
|
||
# pages ready | ||
$(document).ready -> | ||
$("textarea").bind "keydown","ctrl+return",(el) -> | ||
if $(el.target).val().trim().length > 0 | ||
$("#reply > form").submit() | ||
return false | ||
|
||
Posts.initCloseWarning($("textarea.closewarning")) | ||
$("textarea").autogrow() | ||
Posts.initUploader() | ||
|
||
Posts.hookPreview($(".editor_toolbar"), $(".post_editor")) | ||
|
||
$("body").bind "keydown", "m", (el) -> | ||
$('#markdown_help_tip_modal').modal | ||
keyboard : true | ||
backdrop : true | ||
show : true | ||
|
||
# Focus title field in new-post page | ||
$("body.posts-controller.new-action #post_title").focus() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Keyboard shortcuts for browsing pages of lists | ||
(function($) { | ||
$(document).keydown(handleKey); | ||
function handleKey(e) { | ||
var left_arrow = 37; | ||
var right_arrow = 39; | ||
if (e.target.nodeName == 'BODY' || e.target.nodeName == 'HTML') { | ||
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { | ||
var code = e.which; | ||
if (code == left_arrow) { | ||
prevPage(); | ||
} | ||
else if (code == right_arrow) { | ||
nextPage(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
function prevPage() { | ||
var href = $('.pagination .previous_page a').attr('href'); | ||
if (href && href != document.location) { | ||
document.location = href; | ||
} | ||
} | ||
|
||
function nextPage() { | ||
var href = $('.pagination .next_page a').attr('href'); | ||
if (href && href != document.location) { | ||
document.location = href; | ||
} | ||
} | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
* | ||
*= require bootstrap.min | ||
*= require style | ||
*= require_tree ./sprites/ | ||
*= require_self | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Place all the styles related to the cpanel::photos controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ | ||
|
||
|
||
|
||
|
Oops, something went wrong.