Merge branch 'master' of github.com:Rulingcom/NCCU

This commit is contained in:
Matthew K. Fu JuYuan 2012-08-14 13:13:25 +08:00
commit e57b429398
31 changed files with 227 additions and 164 deletions

View File

@ -1,75 +0,0 @@
$(document).on('click', '#ajax_form_submit', function(){
// $('#ajaxForm').ajaxSubmit({
// beforeSubmit: function(a,f,o) {
// o.dataType = 'script';
// if (o.dataType == 'script') {
// o.url = o.url.split('?'); // split on GET params
// if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js
// o.url = o.url.join('?'); // join on GET params
// }
// },
// success: function(response,status,xhr){
// alert(response);
// alert(status);
// alert(xhr);
// },
// error:function(){
// alert("error");
// }
// });
var o = {
// dataType: 'script',
dataType: 'html',
url:$("#ajaxForm").attr("action"),
success: function(response,status,xhr){
if(typeof tinyMCEPopup != "undefined"){
var x = response.split("#");
var returnurl = x[0],
returntitle = x[1],
returndescription = x[2];
var win = tinyMCEPopup.getWindowArg("window");
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = returnurl;
win.document.getElementById(tinyMCEPopup.getWindowArg("alt")).value = returndescription;
win.document.getElementById(tinyMCEPopup.getWindowArg("title")).value = returntitle;
if (typeof(win.ImageDialog) != "undefined") {
// we are, so update image dimensions...
if (win.ImageDialog.getImageData)
win.ImageDialog.getImageData();
// ... and preview if necessary
if (win.ImageDialog.showPreviewImage)
win.ImageDialog.showPreviewImage(returnurl);
}
tinyMCEPopup.close();
}else{
//incase if we want to do something for quick edit file upload
// $("#modal-file").modal('hide');
// var r = "";
// if(rcom.getInternetExplorerVersion() > -1){
// r = "<tr><td>" + response + "</td></tr>";
// r = r.replace("</a><a","</a></td><td><a");
// r = $(r);
// r.attr("id",r.find("span").attr("for"));
// alert(r.html())
// }else{
// r = $(response);
// }
// $('#bulletin_files tbody').append(r);
//$(response).fadeIn();
}
},
error:function(){
alert("error");
}
}
if (o.dataType == 'script') {
o.url = o.url.split('?'); // split on GET params
if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js
o.url = o.url.join('?'); // join on GET params
}
$('#ajaxForm').ajaxSubmit(o);
});

View File

@ -0,0 +1,111 @@
<%#= encoding: utf-8 %>
$(document).on('click', '#ajax_form_submit', function(){
// $('#ajaxForm').ajaxSubmit({
// beforeSubmit: function(a,f,o) {
// o.dataType = 'script';
// if (o.dataType == 'script') {
// o.url = o.url.split('?'); // split on GET params
// if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js
// o.url = o.url.join('?'); // join on GET params
// }
// },
// success: function(response,status,xhr){
// alert(response);
// alert(status);
// alert(xhr);
// },
// error:function(){
// alert("error");
// }
// });
var o = {
// dataType: 'script',
dataType: 'html',
url:$("#ajaxForm").attr("action"),
beforeSubmit: function(){
var sub = true;
$("span.error").remove();
$("#dyn_error").empty();
$("#ajaxForm input").each(function(){
if($(this).val() == ""){
$("<span class='error'> *</span>").insertAfter($(this));
sub = false;
}
})
if(!sub){
$("#dyn_error").text("Cannot be empty.");
$("#dyn_error").text("<%= I18n.t('cant_empty_star') %>");
return false;
}
},
success: function(response,status,xhr){
if(typeof tinyMCEPopup != "undefined"){
var x = response.split("#");
var returnurl = x[0],
returntitle = x[1],
returndescription = x[2];
var win = tinyMCEPopup.getWindowArg("window");
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = returnurl;
win.document.getElementById(tinyMCEPopup.getWindowArg("alt")).value = returndescription;
win.document.getElementById(tinyMCEPopup.getWindowArg("title")).value = returntitle;
if (typeof(win.ImageDialog) != "undefined") {
// we are, so update image dimensions...
if (win.ImageDialog.getImageData)
win.ImageDialog.getImageData();
// ... and preview if necessary
if (win.ImageDialog.showPreviewImage)
win.ImageDialog.showPreviewImage(returnurl);
}
tinyMCEPopup.close();
}else{
//incase if we want to do something for quick edit file upload
// var modalvalues = "";
// var r = "";
// if(rcom.getInternetExplorerVersion() > -1){
// r = "<tr><td>" + response + "</td></tr>";
// r = r.replace("**","</td><td>");
// r = r.replace("**","</td><td>");
// r = $(r);
// modalvalues = r.find("span").attr("data-content").split("#");
// r.attr("id",r.find("span").attr("for"));
// var table=document.getElementById(modalvalues[0]);
// //var tbody = table.getElementsByTagName("tbody");
// var row = table.insertRow(table.rows.length-1);
// var c1 = row.insertCell(0),
// c2 = row.insertCell(1),
// c3 = row.insertCell(2);
// c1.innerHTML = r.find("td").eq(0).html();
// c2.innerHTML = r.find("td").eq(1).html();
// c3.innerHTML = r.find("td").eq(2).html();
// var trow = $("#bulletin_files tfoot").find("tr").eq(0);
// $("#bulletin_files tbody").append(trow);
// }else{
// response = response.replace("**","");
// response = response.replace("**","");
// r = $(response);
// modalvalues = r.find("span").attr("data-content").split("#");
// $('#' + modalvalues[0]+ ' tbody').append(r);
// }
// console.log(modalvalues[1]);
// $("#"+modalvalues[1]).modal('hide');
//$('#bulletin_files tbody').append(r);
//$(response).fadeIn();
}
},
error:function(){
alert("error");
}
}
if (o.dataType == 'script') {
o.url = o.url.split('?'); // split on GET params
if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js
o.url = o.url.join('?'); // join on GET params
}
$('#ajaxForm').ajaxSubmit(o);
});

View File

@ -0,0 +1,9 @@
/**
* jQuery.Preload - Multifunctional preloader
* Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com
* Dual licensed under MIT and GPL.
* Date: 3/25/2009
* @author Ariel Flesler
* @version 1.0.8
*/
;(function($){var h=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},h.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null}),data={loaded:0,failed:0,next:0,done:0,total:f.length};if(!data.total)return finish();var g=$(Array(d.threshold+1).join('<img/>')).load(handler).error(handler).bind('abort',handler).each(fetch);function handler(e){data.element=this;data.found=e.type=='load';data.image=this.src;data.index=this.index;var a=data.original=c[this.index];data[data.found?'loaded':'failed']++;data.done++;if(d.enforceCache)h.cache.push($('<img/>').attr('src',data.image)[0]);if(d.placeholder&&a.src)a.src=data.found?data.image:d.notFound||a.src;if(d.onComplete)d.onComplete(data);if(data.done<data.total)fetch(0,this);else{if(g&&g.unbind)g.unbind('load').unbind('error').unbind('abort');g=null;finish()}};function fetch(i,a,b){if(a.attachEvent&&data.next&&data.next%h.gap==0&&!b){setTimeout(function(){fetch(i,a,1)},0);return!1}if(data.next==data.total)return!1;a.index=data.next;a.src=f[data.next++];if(d.onRequest){data.index=a.index;data.element=a;data.image=a.src;data.original=c[data.next-1];d.onRequest(data)}};function finish(){if(d.onFinish)d.onFinish(data)}};h.gap=14;h.cache=[];h.defaults={threshold:2,base:'',ext:'',replace:''};$.fn.preload=function(a){h(this,a);return this}})(jQuery);

View File

@ -1,5 +1,14 @@
$(document).on('click', '.list-remove', function(){
$('#delete_all').submit();
var a = [];
$('.checkbox_in_list').each(function(){
if (this.checked) a.push("ids[]=" + this.value);
});
var url = $(this).attr('rel');
if (url.indexOf('?') > -1){
$.getScript(url + '&' + a.join('&'));
}else{
$.getScript(url + '?' + a.join('&'));
}
});
$(document).on('click', '#check_all', function(){

View File

@ -11,3 +11,7 @@
.warning{
color:orange;
}
label#dyn_error {
margin-left: 50%;
}

View File

@ -87,8 +87,8 @@ class Admin::AssetsController < OrbitBackendController
end
def delete
if params[:to_delete]
asset = Asset.any_in(:_id => params[:to_delete]).delete_all
if params[:ids]
asset = Asset.any_in(:_id => params[:ids]).delete_all
end
redirect_to assets_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end

View File

@ -86,8 +86,8 @@ class Admin::DesignsController < OrbitBackendController
end
def delete
if params[:to_delete]
designs = Design.any_in(:_id => params[:to_delete]).delete_all
if params[:ids]
designs = Design.any_in(:_id => params[:ids]).delete_all
end
redirect_to admin_designs_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end

View File

@ -160,6 +160,7 @@ module ApplicationHelper
javascripts << "<script type='text/javascript' src='/assets/orbit_bar.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/orbit-bar-search.js'></script>\n"
end
javascripts << "<script type='text/javascript' src='/assets/lib/jquery.preload-min.js'></script>\n"
javascripts << "<script type='text/javascript' src='/static/jquery.cycle.all.latest.js'></script>\n"
javascripts << "<script type='text/javascript' src='/static/kernel.js'></script>\n"
# javascripts << "<script type='text/javascript' src='/assets/social-share-button.js'></script>\n"

View File

@ -20,13 +20,13 @@ module OrbitBackendHelper
' active' if (@filter[type].include?(id.to_s) rescue nil)
end
def render_sort_bar(delete_all, *titles)
def render_sort_bar(delete_all, url, *titles)
content_tag :table, :class => "table main-list" do
content_tag :thead do
content_tag :tr, :class => "sort-header" do
concat (content_tag :th, :class => "span1 strong" do
concat check_box_tag :check_all
concat link_to content_tag(:i, nil, :class => "icon-trash"), '#', :class => "list-remove"
concat link_to content_tag(:i, nil, :class => "icon-trash"), '#', :class => "list-remove", :rel => url
end) if (delete_all && (is_admin? || (is_manager? rescue nil)))
titles.each do |title|
concat render_title(title[0], title[1], title[2], title[3])

View File

@ -1,4 +1,5 @@
<%= render_sort_bar(true, ['title', 'title','span4', 'admin.title'],
<%= render_sort_bar(true, delete_admin_assets_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]),
['title', 'title','span4', 'admin.title'],
['description', 'description', 'span1-2', 'admin.data'],
['intro', 'intro', 'span1-2', 'admin.file_type'],
['intro', 'intro', 'span1-2', 'admin.file_length'],

View File

@ -9,6 +9,7 @@
<div class="modal-header">
<h3><%= t 'admin.file_upload' %></h3>
</div>
<label class="control-label error" id="dyn_error"></label>
<div class="modal-body form-horizontal">
<div class="control-group">
<label for="title" class="control-label error"><%= t 'admin.title' %></label>

View File

@ -1,4 +1,3 @@
<%= form_for :assets, :url => delete_admin_assets_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]), :html => {:id => 'delete_all'}, :remote => true do %>
<%= render 'filter' %>
<table id="asset_sort_list" class="table main-list">
<thead>
@ -16,7 +15,6 @@
<%= render :partial => 'asset', :collection => @assets %>
</tbody>
</table>
<% end %>
<div class="form-actions form-fixed pagination-right">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_admin_asset_path, :remote => true, :class => 'btn btn-primary pull-right' %>

View File

@ -1,3 +1,4 @@
<%= render_sort_bar(true, ['title', 'title','span7', 'admin.title'],
<%= render_sort_bar(true, delete_admin_designs_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]),
['title', 'title','span7', 'admin.title'],
['author', 'author', 'span2', 'admin.author'],
['intro', 'intro', 'span2', 'admin.intro']).html_safe %>

View File

@ -2,12 +2,10 @@
<%= render 'admin/sites/side_bar' %>
<% end %>
<%= form_for :news_bulletins, :url => delete_admin_designs_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]), :html => {:id => 'delete_all'}, :remote => true do %>
<%= render 'filter' %>
<table class="table main-list">
<%= render 'designs' %>
</table>
<% end %>
<div class="form-actions form-fixed pagination-right">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_admin_design_path, :class => 'btn btn-primary' %>

View File

@ -11,6 +11,7 @@ en:
back: Back
browse: Browse
cancel: Cancel
cant_empty_star: Cannot be empty (*)
create_fail: Creation failed
create: Create
delete: Delete

View File

@ -8,6 +8,7 @@ zh_tw:
back: 回上一步
browse: 選擇檔案
cancel: 取消
cant_empty_star: 不能為空 (*)
create: 新增
create_fail: 創建失敗
delete: 刪除

View File

@ -17,7 +17,7 @@ Orbit::Application.routes.draw do
resources :assets do
collection do
get 'file_upload'
post 'delete'
get 'delete'
end
end
resources :asset_categories
@ -53,7 +53,7 @@ Orbit::Application.routes.draw do
resources :designs do
collection do
get 'upload_package'
post 'delete'
get 'delete'
post 'upload_package'
end
member do

View File

@ -44,7 +44,12 @@ module ParserCommon
ad_banner = AdBanner.find(banner["id"]) rescue nil
if ad_banner
res << "<script type='text/javascript'>
$(document).ready(function(){
jQuery(function( $ ){
$.preload( '#slideshow-#{ad_banner.title.dehumanize} img', {
onFinish:finish,
threshold: 2 //'2' is the default, how many at a time, to load.
});
function finish(){
$('#slideshow-#{ad_banner.title.dehumanize}').cycle({
delay: -1000,
fx: '#{ad_banner.ad_fx.nil? ? 'fade': ad_banner.ad_fx}',
@ -54,6 +59,7 @@ module ParserCommon
return \"<li><a href='#'></a></li>\";
}
});
};
});
</script>"
res << "<ul id='banner_nav' class='clear'></ul>"
@ -74,7 +80,7 @@ module ParserCommon
res << "link_open='#{ad_image.link_open}' "
# res << "link_url='#{(ad_image.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
res << "link_url='#{(ad_image.out_link)}' "
res << "style='cursor:pointer'" if !ad_image.out_link.blank?
res << "style='cursor:pointer; visibility='hidden'" if !ad_image.out_link.blank?
res << "/>"
end
res << "</div>"

View File

@ -291,8 +291,8 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
end
def delete
if params[:to_delete]
bulletins = Bulletin.any_in(:_id => params[:to_delete]).delete_all
if params[:ids]
bulletins = Bulletin.any_in(:_id => params[:ids]).delete_all
end
redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end

View File

@ -1,4 +1,5 @@
<%= render_sort_bar(true, ['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', 'bulletin.status'],
<%= render_sort_bar(true, delete_panel_announcement_back_end_bulletins_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]),
['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', 'bulletin.status'],
['category', 'bulletin_category', 'span1-2', 'bulletin.category'],
['title', 'title','span7', 'bulletin.title'],
['start_date', 'postdate', 'span1-2', 'bulletin.start_date'],

View File

@ -1,9 +1,7 @@
<%= form_for :bulletins, :url => delete_panel_announcement_back_end_bulletins_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]), :html => {:id => 'delete_all'}, :remote => true do %>
<%= render 'filter' %>
<table id="bulettin_sort_list" class="table main-list">
<%= render 'bulletins' %>
</table>
<% end %>
<div class="form-actions form-fixed pagination-right">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary pull-right' %>

View File

@ -15,7 +15,7 @@ Rails.application.routes.draw do
get 'load_quick_edit'
end
collection do
post 'delete'
get 'delete'
end
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit

View File

@ -328,8 +328,8 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
end
def delete
if params[:to_delete]
news_bulletins = NewsBulletin.any_in(:_id => params[:to_delete]).delete_all
if params[:ids]
news_bulletins = NewsBulletin.any_in(:_id => params[:ids]).delete_all
end
redirect_to panel_news_back_end_news_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end

View File

@ -1,4 +1,5 @@
<%= render_sort_bar(true, ['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', 'news_bulletin.status'],
<%= render_sort_bar(true, delete_panel_news_back_end_news_bulletins_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]),
['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', 'news_bulletin.status'],
['category', 'news_bulletin_category', 'span1-2', 'news_bulletin.category'],
['title', 'title','span7', 'news_bulletin.title'],
['start_date', 'postdate', 'span1-2', 'news_bulletin.start_date'],

View File

@ -1,9 +1,7 @@
<%= form_for :news_bulletins, :url => delete_panel_news_back_end_news_bulletins_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]), :html => {:id => 'delete_all'}, :remote => true do %>
<%= render 'filter' %>
<table id="bulettin_sort_list" class="table main-list">
<%= render 'news_bulletins' %>
</table>
<% end %>
<div class="form-actions form-fixed pagination-right">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_news_back_end_news_bulletin_path, :class => 'btn btn-primary' %>

View File

@ -15,7 +15,7 @@ Rails.application.routes.draw do
get 'load_quick_edit'
end
collection do
post 'delete'
get 'delete'
end
match "file_quick_add/:news_bulletin_id" => "news_bulletins#file_quick_add" ,:as => :file_quick_add
match "file_quick_edit/:news_bulletin_id" => "news_bulletins#file_quick_edit" ,:as => :file_quick_edit

View File

@ -1,4 +1,4 @@
<%= render_sort_bar(false, ['name', 'page','span7', 'page_context.name'],
<%= render_sort_bar(false, nil, ['name', 'page','span7', 'page_context.name'],
['version', 'version', 'span2', 'page_context.version'],
['update_time', 'updated_at', 'span2', 'page_context.update_time'],
['last_modified', 'update_user_id', 'span2', 'page_context.last_modified']).html_safe %>

View File

@ -124,8 +124,8 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
end
def delete
if params[:to_delete]
web_links = WebLink.any_in(:_id => params[:to_delete]).delete_all
if params[:ids]
web_links = WebLink.any_in(:_id => params[:ids]).delete_all
end
redirect_to panel_web_resource_back_end_web_links_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end

View File

@ -1,4 +1,5 @@
<%= render_sort_bar(true, ['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1', 'bulletin.status'],
<%= render_sort_bar(true, delete_panel_web_resource_back_end_web_links_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]),
['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1', 'bulletin.status'],
['category', 'bulletin_category', 'span2', 'bulletin.category'],
['title', 'title','span3', 'bulletin.title'],
['tags', 'tags', 'span2', 'bulletin.tags']).html_safe %>

View File

@ -1,4 +1,3 @@
<%= form_for :news_bulletins, :url => delete_panel_web_resource_back_end_web_links_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]), :html => {:id => 'delete_all'}, :remote => true do %>
<%= render 'filter' %>
<table class="table main-list">
<thead>
@ -14,7 +13,6 @@
<%= render :partial => 'web_link', :collection => @web_links %>
</tbody>
</table>
<% end %>
<div class="form-actions form-fixed pagination-right">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_panel_web_resource_back_end_web_link_path, :class => 'btn btn-primary pull-right' %>

View File

@ -6,7 +6,7 @@ Rails.application.routes.draw do
root :to => "web_links#index"
resources :web_links do
collection do
post 'delete'
get 'delete'
end
end
resources :web_link_categorys