Compare commits

..
9 changed files with 165 additions and 121 deletions

No files matched your search

+34 -1
View File
@@ -541,6 +541,8 @@ function changeStatusHidden() {
// Document Ready
$(function() {
showFiltersOnPageRefresh();
new ini();
$('#main-wrap').on('click', '.delete', function() {
api.modal($(this).attr('rel'));
@@ -589,4 +591,35 @@ $(function() {
}
formTip()
sidebarNav();
});
});
var showFiltersOnPageRefresh = function(){
var params = getUrlVars(),
paramfilter = params['new_filter[type]'];
// switch (paramfilter){
// case "role":
// paramfilter = "status";
// break;
// }
if( paramfilter ){
$( "#filter" ).addClass('open');
$( '#filter a[href="#collapse-' + paramfilter + '"]').parent().parent().addClass('active');
$( '#filter #collapse-' + paramfilter ).addClass('in');
}
}
var getUrlVars = function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++){
hash = hashes[i].split('=');
vars.push(decodeURIComponent(hash[0]));
vars[decodeURIComponent(hash[0])] = decodeURIComponent(hash[1]);
}
if(vars[0] == window.location.href){
vars =[];
}
return vars;
}
+39 -22
View File
@@ -81,7 +81,7 @@ function customOpenSlide() {
} else {
$('#pageslide form').prop('method', 'post')
};
_type == 'page' ? pageSetting(element.data('id'), _edit) : linkSetting(element.data('id'), _edit, pageslide);
_type == 'page' ? pageSetting(element.data('id'), _edit, pageslide) : linkSetting(element.data('id'), _edit, pageslide);
}
});
$iFrame.pageslide({
@@ -130,12 +130,13 @@ function iFrameContent() {
}).css('cursor', 'default');
}
$('#pageslide_iframe').load(function() {
var $iContents = $(this).contents(),
$pc = $iContents.find('.page_content');
$(this).get(0).contentWindow.externalFunction(iFrameFunction, $iContents, $pc);
var $iContents = $(this).contents(),
$pc = $iContents.find('.page_content');
iFrameFunction($iContents, $pc);
});
}
function pageSetting(id, edit) {
function pageSetting(id, edit, ps) {
$pageModule = $('#pageslide #page_module_app_id');
$pageF2E = $('#pageslide #page_app_frontend_url');
$pageDivF2E = $('#pageslide #front_url');
@@ -183,23 +184,25 @@ function pageSetting(id, edit) {
if(val.category.length > 0) {
$.each(val.category, function(index, val) {
var _arr = $.inArray($(this)[1], _selectData.module.category[1]);
var _arr = $.inArray($(this)[1], _selectData.module.category);
$pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
if(!_selectData.module.category[0] && _arr !== -1) {
if(_arr !== -1) {
$pageCategory.find('input[type="checkbox"]').eq(index).prop('checked', true);
}
_selectData.module.category[0] ? $pageCategory.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
var $all = $pageCategory.siblings('.checkbox').children('.select_all')
_selectData.module.category.length > 1 && _selectData.module.category.length == index + 1 ? $all.prop('checked', true) : $all.prop('checked', false);
});
$pageCategoryGroup.show();
}
if(val.tags.length > 0) {
$.each(val.tags, function(index, val) {
var _arr = $.inArray($(this)[1], _selectData.module.tags[1]);
var _arr = $.inArray($(this)[1], _selectData.module.tags);
$pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
if(!_selectData.module.tags[0] && _arr !== -1) {
if(_arr !== -1) {
$pageTags.find('input[type="checkbox"]').eq(index).prop('checked', true);
}
_selectData.module.tags[0] ? $pageTags.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
var $all = $pageTags.siblings('.checkbox').children('.select_all')
_selectData.module.tags.length > 1 && _selectData.module.tags.length == index + 1 ? $all.prop('checked', true) : $all.prop('checked', false);
});
$pageTagsGroup.show();
}
@@ -397,12 +400,13 @@ $(function() {
if(val.category.length > 0) {
$.each(val.category, function(index, val) {
if(val !== 0) {
var _arr = _select ? $.inArray($(this)[1], _select.category[1]) : '';
var _arr = _select ? $.inArray($(this)[1], _select.category) : '';
$pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
if(_select && !_select.category[0] && _arr !== -1) {
if(_boolean && _arr !== -1) {
$pageCategory.find('input[type="checkbox"]').eq(index).prop('checked', true);
}
_select && _val == _select.main && _select.category[0] ? $pageCategory.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
var $all = $pageCategory.siblings('.checkbox').children('.select_all');
_boolean && _val == _select.main && _select.category.length > 1 && _select.category.length == index + 1 ? $all.prop('checked', true) : $all.prop('checked', false);
}
});
$pageCategoryGroup.show();
@@ -413,12 +417,13 @@ $(function() {
if(val.tags.length > 0) {
$.each(val.tags, function(index, val) {
if(val !== 0) {
var _arr = _select ? $.inArray($(this)[1], _select.tags[1]) : '';
var _arr = _select ? $.inArray($(this)[1], _select.tags) : '';
$pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
if(_select && !_select.tags[0] && _arr !== -1) {
if(_boolean && _arr !== -1) {
$pageTags.find('input[type="checkbox"]').eq(index).prop('checked', true);
}
_select && _val == _select.main && _select.tags[0] ? $pageTags.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
var $all = $pageTags.siblings('.checkbox').children('.select_all');
_boolean && _val == _select.main && _select.tags.length > 1 && _select.tags.length == index + 1 ? $all.prop('checked', true) : $all.prop('checked', false);
}
});
$pageTagsGroup.show();
@@ -451,12 +456,16 @@ $(function() {
$('#pageslide').on('change', '.checkbox-groups input', function(event) {
var $checked = $(this);
if($checked.attr('type') == 'checkbox') {
if($checked.hasClass('select_all') && $checked.prop('checked')) {
$checked.closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', false);
} else if($checked.prop('checked') && !$checked.hasClass('lang-enable')) {
$checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', false);
} else {
if($checked.hasClass('select_all')) {
if($checked.prop('checked')) {
$checked.closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', true);
} else {
$checked.closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', false);
}
} else if($checked.hasClass('lang-enable')) {
var checkboxes = $checked.closest('.groups').find('input[type="checkbox"]');
if($checked.prop('checked')) {
$checked.closest('.active-link').addClass('active').siblings('active-link').removeClass('active').end().find('.active-mune').slideDown(300);
if(_status) {
@@ -470,6 +479,14 @@ $(function() {
$(this).find('input:eq(0)').prop('checked', true);
})
}
} else {
var _l = $checked.closest('.groups').find('input[type="checkbox"]').length,
_c = $checked.closest('.groups').find('input[type="checkbox"]:checked').length;
if(_l == _c) {
$checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', true)
} else {
$checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', false)
};
}
return false;
} else if($checked.attr('type') == 'radio' && !$(this).closest('div').hasClass('active-mune')) {
+57 -84
View File
@@ -1,93 +1,66 @@
//Preview need a link in form as Ex and a corresponding PUT action in controller
//Ex preview trigger:
// <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%>
$(function() {
// $(".post_preview").click(function(e){
// $("#main-wrap").after("<span id='show_preview'></span>");
// e.preventDefault();
// var form = $(this).parents("form").first()
// //var cont = form["content"].value;
// // $.ajax({
// // type: 'POST',
// // url: $(this).attr("href")+'?preview=true',
// // data: form.serialize(),
// // dataType: "script",
// // success: function (msg) {
// // $("#"+start_modal_with_id).modal('show'); },
// // error: function(){
// // alert("ERROR");
// // }
// // });
// url = "/panel/news/back_end/news_bulletins/preview?preview=true"
// // alert(url)
// form.attr("action",url);
// form.submit();
// //return false;
// });
// /panel/announcement/back_end/bulletins/preview
$('#main-wrap').on(clickEvent, '.post_preview, .preview_trigger', function(e) {
$(".post_preview").click(function(){
$("#main-wrap").after("<span id='show_preview'></span>");
if($(this).hasClass('post_preview')) {
var attrs = e.target.attributes;
var url = attrs['url'];
$("form.previewable").ajaxSubmit({
beforeSubmit: function(a,f,o){
o.dataType = 'script';
o.url = url.nodeValue;
o.type = 'post';
},success: function(msg) {
$('#show_preview .modal').modal()
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
});
}
$.post($(this).attr('url'), $(".previewable").serialize() ,function(data){
$('#show_preview .modal').modal();
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
});
} else if($(this).hasClass('preview_trigger')) {
$.ajax({
type: 'PUT',
url: $(this).attr("href"),
data: $(this).parents("form").serialize(),
success: function (msg) {
$('#show_preview .modal').modal();
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
});
},
error: function(){
alert("ERROR");
}
});
return false;
}
},'script');
});
// $("a.preview_trigger").on('click',function(){
$(".preview_trigger").click(function(){
$("#main-wrap").after("<span id='show_preview'></span>");
$.ajax({
type: 'PUT',
url: $(this).attr("href"),
data: $(this).parents("form").serialize(),
success: function (msg) {
$('#show_preview .modal').modal();
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
});
},
error: function(){
alert("ERROR");
}
});
return false;
});
// $('#main-wrap').on(clickEvent, '.post_preview, .preview_trigger', function(e) {
// $("#main-wrap").after("<span id='show_preview'></span>");
// $.ajax({
// type: 'PUT',
// url:$(this).attr("href"),
// data:$(this).parents("form").serialize(),
// success: function (msg) {
// $("#"+start_modal_with_id).modal('show'); },
// error: function(){
// alert("ERROR");
// if($(this).hasClass('post_preview')) {
// var attrs = e.target.attributes;
// var url = attrs['url'];
// $("form.previewable").ajaxSubmit({
// beforeSubmit: function(a,f,o){
// o.dataType = 'script';
// o.url = url.nodeValue;
// o.type = 'post';
// },success: function(msg) {
// $('#show_preview .modal').modal()
// $('#show_preview .modal').height(function() {
// return $(window).height() * 0.7;
// });
// }
// });
// } else if($(this).hasClass('preview_trigger')) {
// $.ajax({
// type: 'PUT',
// url: $(this).attr("href"),
// data: $(this).parents("form").serialize(),
// success: function (msg) {
// $('#show_preview .modal').modal();
// $('#show_preview .modal').height(function() {
// return $(window).height() * 0.7;
// });
// },
// error: function(){
// alert("ERROR");
// }
// });
// return false;
// });
// return false;
// }
// });
// $("form.nccu_ajax_form").ajaxForm({
// beforeSubmit: function(a,f,o) {
// // if(clicked_what.hasClass("post_preview")){
// // $("#main-wrap").after("<span id='show_preview'></span>");
// // o.dataType = 'script';
// // o.url = clicked_what.attr("url");
// // }
// },
// success: function(data) {
// // if(!clicked_what.hasClass("post_preview")){
// // window.location = data.redirect_url;
// // }
// }
// })
});
@@ -95,9 +95,7 @@ class Admin::PagePartsController < OrbitBackendController
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
flash.now[:notice] = t('update.success.content')
respond_to do |format|
format.html {
redirect_to admin_page_url(@part.page, edit: true)
}
format.js
end
else
@id = params[:id]
+2 -2
View File
@@ -60,8 +60,8 @@ class Admin::PagesController < Admin::ItemsController
m = {}
m["main"] = page.module_app_id.to_s
m["sub"] = page.app_frontend_url
m["category"] = page.category.present? ? [0, page.category.map{|c| c.to_s}] : [1]
m["tags"] = page.tag.present? ? [0, page.tag.map{|c| c.to_s}] : [1]
m["category"] = page.category.present? ? page.category.map{|c| c.to_s} : []
m["tags"] = page.tag.present? ? page.tag.map{|c| c.to_s} : []
m["public"] = page.is_published ? 1 : 0
m["link"] = @site_valid_locales.inject([]) do |link, locale|
link << [locale, (page.enabled_for && page.enabled_for.include?(locale)) ? 1 : 0, (page.menu_enabled_for && page.menu_enabled_for[locale].eql?('true')) ? 1 :0]
+13 -7
View File
@@ -3,8 +3,7 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/items/page_part" %>
<% end %>
<%= form_for @part, url: admin_page_part_path(@part), html: { class: "form-horizontal main-forms"} do |f| %>
<%= form_for @part, url: {action: "update"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %>
<%= f.error_messages %>
<div class="btn-group" data-toggle="buttons-radio">
<label href="#none" class="btn btn-large" data-toggle="tab">
@@ -81,7 +80,7 @@
<div class="control-group input-content">
<%= f.label :locale, "#{t(:title)} #{I18nVariable.from_locale(locale)}", class: "control-label muted" %>
<div class="controls">
<%= f.text_field locale, class: 'input-xlarge page_title', placeholder: "#{t(:title)} #{I18nVariable.from_locale(locale)}", id: locale %>
<%= f.text_field locale, class: 'input-xlarge page_title', placeholder: "#{t(:title)} #{I18nVariable.from_locale(locale)}", id: locale, :value => (@part.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
@@ -102,13 +101,13 @@
<%= f.label :categories, t(:categories), class: "control-label muted" %>
<div class="controls">
<%= content_tag :label, class: "checkbox" do %>
<%= check_box_tag nil, nil, true, class: "select_all" %> <%= t(:all) %>
<%= check_box_tag nil, nil, false, class: "select_all" %> <%= t(:all) %>
<% end %>
<div class="groups" id="page-category">
<%= content_tag_for(:label, @module_app_categories, class: "checkbox inline") do |category|%>
<%= check_box_tag("page_part[tag][]", category.id, (@part.category.include?(category.id) rescue false) ) %>
<%= check_box_tag("page_part[category][]", category.id, (@part.category.include?(category.id.to_s) rescue false) ) %>
<%= category.title %>
<% end if @module_app_tags %>
<% end if @module_app_categories %>
</div>
</div>
</div>
@@ -120,7 +119,7 @@
<% end %>
<div class="groups" id="page-tags">
<%= content_tag_for(:label, @module_app_tags, class: "checkbox inline") do |tag|%>
<%= check_box_tag("page_part[tag][]", tag.id, (@part.tag.include?(tag.id) rescue false) ) %>
<%= check_box_tag("page_part[tag][]", tag.id, (@part.tag.include?(tag.id.to_s) rescue false) ) %>
<%= tag.name %>
<% end if @module_app_tags %>
</div>
@@ -161,3 +160,10 @@
$.getScript($(this).attr('rel') + '?type=' + $(this).val() + "&id=" + "<%= @part.id %>" );
});
</script>
<script>
function toggleChecked(status) {
$(".checkbox").each( function() {
$(this).attr("checked",status);
})
}
</script>
+1
View File
@@ -0,0 +1 @@
window.location.href="<%= admin_page_url(@part.page, edit: true) %>"
@@ -24,12 +24,12 @@
<ul class="nav nav-pills filter-nav pull-right">
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-status" data-toggle="collapse" data-parent="#filter" class="accordion-toggle">Roles</a>
<a href="#collapse-role" data-toggle="collapse" data-parent="#filter" class="accordion-toggle">Roles</a>
</div>
</li>
</ul>
<div class="filter-group accordion-group">
<div class="accordion-body collapse" id="collapse-status">
<div class="accordion-body collapse" id="collapse-role">
<%= render :partial => "filter"%>
@@ -13,13 +13,21 @@
<div>
<script type="text/javascript" src="/assets/kernel.js"></script>
<script type="text/javascript">
var preview_img;
$(function() {
$("iframe").load(function() {
// Get the body element
var frameBody = $("iframe").contents().find('body');
// Get all links inside the BODY tag
$("iframe").contents().find('#orbit-bar').hide();
$('.thumbnail').each(function(){
if($(this).children('img').length) preview_img = $(this).children('img').attr('src');
});
InsertPreviewImage();
frameBody.find('a').click(function(e){
//Disable all default actions
e.preventDefault();
@@ -30,6 +38,14 @@
$("#show_preview").remove();
});
});
function InsertPreviewImage(){
if($("iframe").contents().find('.news_image').length){
$("iframe").contents().find('.news_image').append("<a href='' target='_blank'><img src='"+preview_img+"' width='320' height='240' /></a>");
}else{
setTimeout(InsertPreviewImage,1000);
}
}
</script>
</div>
</div>