brand new parser for orbit 4.5 and some other changes

This commit is contained in:
Harry Bomrah 2014-05-14 19:47:25 +08:00
parent d8f423de07
commit 2fdc99dfbd
22 changed files with 184 additions and 203 deletions

View File

@ -1,81 +0,0 @@
function slideshow (element, bannerEffect, bannerTime, bannerSpeed) {
element.cycle('destroy');
element.children('img').removeAttr('class');;
element.cycle({
fx: bannerEffect,
timeout: bannerTime,
speed: bannerSpeed,
});
};
function setSlideshow(element, data) {
$("#pageslide .ad_banner_ad_fx").children('option:selected').each(function(index, el) {
$(this).val() == 'flipHorz' || $(this).val() == 'flipVert' ? $('.suckIE').show() : $('.suckIE').hide();
});
slideshow(element, data['fx'], 2000, 1000);
}
function preview() {
$('.open-modal').on('click', function() {
var _data = $(this).data();
bannerName = _data.name;
bannerEffect = _data.fx;
bannerTime = _data.time;
bannerSpeed = _data.speed;
bannerW = _data.w;
bannerH = _data.h;
$('#preview').modal('show');
});
$('#preview').on('shown', function() {
$(this).attr('aria-labelledby', bannerName.toString()).find('h3').text(bannerName.toString())
if(bannerW > 500) {
var resize = 500/bannerW
bannerW = Math.floor(bannerW*resize);
bannerH = Math.floor(bannerH*resize);
console.log(bannerW)
};
if(bannerH > 300) {
var resize = 300/bannerH
bannerW = Math.floor(bannerW*resize);
bannerH = Math.floor(bannerH*resize);
}
slideshow($(this).find('.preview'), bannerEffect, bannerTime, bannerSpeed);
$(this).find('.preview').css({
'width': bannerW,
'height': bannerH
});
$(this).find('.preview img').css({
'width': '100%',
'height': '100%'
});
});
$('#preview').on('hidden', function() {
$(this).attr('aria-labelledby', '').find('h3').text('')
$(this).find('.preview').cycle('destroy');
$(this).find('.preview img').removeAttr('style');
});
};
$(function() {
var bannerName = null,
bannerEffect = null,
bannerTime = null,
bannerSpeed = null,
bannerW = null,
bannerH = null,
$preview = $('#pageslide .preview');
$(".ad_banner_ad_fx").change(function () {
var suckIE = false;
// bannerTime = $("#pageslide #timeout").val()*1000;
// bannerSpeed = $("#pageslide #speed").val()*1000;
bannerTime = parseInt(bannerTime) || 300;
bannerSpeed = parseInt(bannerSpeed) || 300;
$(this).children('option:selected').each(function(index, el) {
$(this).val() == 'flipHorz' || $(this).val() == 'flipVert' ? $('.suckIE').show() : $('.suckIE').hide();
});
slideshow($preview, $(this).val(), 2000, 1000);
});
preview();
});

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20130909 */
(function(e){"use strict";function t(t){return{preInit:function(e){e.slides.css(n)},transition:function(i,n,s,o,r){var l=i,c=e(n),a=e(s),d=l.speed/2;t.call(a,-90),a.css({display:"block","background-position":"-90px",opacity:1}),c.css("background-position","0px"),c.animate({backgroundPosition:90},{step:t,duration:d,easing:l.easeOut||l.easing,complete:function(){i.API.updateView(!1,!0),a.animate({backgroundPosition:0},{step:t,duration:d,easing:l.easeIn||l.easing,complete:r})}})}}}function i(t){return function(i){var n=e(this);n.css({"-webkit-transform":"rotate"+t+"("+i+"deg)","-moz-transform":"rotate"+t+"("+i+"deg)","-ms-transform":"rotate"+t+"("+i+"deg)","-o-transform":"rotate"+t+"("+i+"deg)",transform:"rotate"+t+"("+i+"deg)"})}}var n,s=document.createElement("div").style,o=e.fn.cycle.transitions,r=void 0!==s.transform||void 0!==s.MozTransform||void 0!==s.webkitTransform||void 0!==s.oTransform||void 0!==s.msTransform;r&&void 0!==s.msTransform&&(s.msTransform="rotateY(0deg)",s.msTransform||(r=!1)),r?(o.flipHorz=t(i("Y")),o.flipVert=t(i("X")),n={"-webkit-backface-visibility":"hidden","-moz-backface-visibility":"hidden","-o-backface-visibility":"hidden","backface-visibility":"hidden"}):(o.flipHorz=o.scrollHorz,o.flipVert=o.scrollVert||o.scrollHorz)})(jQuery);

View File

@ -1,2 +0,0 @@
/*! Plugin for Cycle2; Copyright (c) 2012 M. Alsup; ver: 20121120 */
(function(a){function b(a,b,c){if(a&&c.style.filter){b._filter=c.style.filter;try{c.style.removeAttribute("filter")}catch(d){}}else!a&&b._filter&&(c.style.filter=b._filter)}"use strict",a.extend(a.fn.cycle.transitions,{fade:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:0,display:"block"}),c.animIn={opacity:1},c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}},fadeout:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:1,display:"block"}),c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}}})})(jQuery);

View File

@ -1,2 +0,0 @@
/*! Plugin for Cycle2; Copyright (c) 2012 M. Alsup; ver: 20121120 */
(function(a){"use strict",a.fn.cycle.transitions.scrollVert={before:function(a,b,c,d){a.API.stackSlides(a,b,c,d);var e=a.container.css("overflow","hidden").height();a.cssBefore={top:d?-e:e,left:0,opacity:1,display:"block"},a.animIn={top:0},a.animOut={top:d?e:-e}}}})(jQuery);

View File

@ -1,2 +0,0 @@
/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20130721 */
(function(e){"use strict";e.fn.cycle.transitions.tileSlide=e.fn.cycle.transitions.tileBlind={before:function(t,i,n,s){t.API.stackSlides(i,n,s),e(i).show(),t.container.css("overflow","hidden"),t.tileDelay=t.tileDelay||"tileSlide"==t.fx?100:125,t.tileCount=t.tileCount||7,t.tileVertical=t.tileVertical!==!1,t.container.data("cycleTileInitialized")||(t.container.on("cycle-destroyed",e.proxy(this.onDestroy,t.API)),t.container.data("cycleTileInitialized",!0))},transition:function(t,i,n,s,o){function r(e){p.eq(e).animate(I,{duration:t.speed,easing:t.easing,complete:function(){(s?v-1===e:0===e)&&t._tileAniCallback()}}),setTimeout(function(){(s?v-1!==e:0!==e)&&r(s?e+1:e-1)},t.tileDelay)}t.slides.not(i).not(n).hide();var c,l,a,d,u,p=e(),f=e(i),y=e(n),v=t.tileCount,h=t.tileVertical,g=t.container.height(),m=t.container.width();h?(l=Math.floor(m/v),d=m-l*(v-1),a=u=g):(l=d=m,a=Math.floor(g/v),u=g-a*(v-1)),t.container.find(".cycle-tiles-container").remove();var I,A={left:0,top:0,overflow:"hidden",position:"absolute",margin:0,padding:0};I=h?"tileSlide"==t.fx?{top:g}:{width:0}:"tileSlide"==t.fx?{left:m}:{height:0};var S=e('<div class="cycle-tiles-container"></div>');S.css({zIndex:f.css("z-index"),overflow:"visible",position:"absolute",top:0,left:0,direction:"ltr"}),S.insertBefore(n);for(var x=0;v>x;x++)c=e("<div></div>").css(A).css({width:v-1===x?d:l,height:v-1===x?u:a,marginLeft:h?x*l:0,marginTop:h?0:x*a}).append(f.clone().css({position:"relative",maxWidth:"none",width:f.width(),margin:0,padding:0,marginLeft:h?-(x*l):0,marginTop:h?0:-(x*a)})),p=p.add(c);S.append(p),f.hide(),y.show().css("opacity",1),r(s?0:v-1),t._tileAniCallback=function(){y.show(),f.hide(),S.remove(),o()}},stopTransition:function(e){e.container.find("*").stop(!0,!0),e._tileAniCallback&&e._tileAniCallback()},onDestroy:function(){var e=this.opts();e.container.find(".cycle-tiles-container").remove()}}})(jQuery);

View File

@ -55,9 +55,9 @@ class PagesController < ApplicationController
@manifest = @key
@dataApi = nil
OrbitHelper.set_params params
OrbitHelper.set_site_locale locale
OrbitHelper.set_this_module_app module_app.singularize
OrbitHelper.set_page_categories page.categories || []
OrbitHelper.set_page_data_count page.data_count
if params[:layout].kind_of?(String)

View File

@ -84,28 +84,56 @@ module ApplicationHelper
end
def render_view
def parsing_repeats_again(elements,d,level)
newhtml = []
oldhtml = []
elements.each do |el|
html_to_render = ""
data_name = el.attr("data-list")
wrap_elements = el.css("*[data-list][data-level='#{level}']")
if d["#{data_name}"]
d["#{data_name}"].each_with_index do |item,i|
element = el.inner_html
if wrap_elements.count > 0
htmls = parsing_repeats_again(wrap_elements,d["#{data_name}"][i], level + 1)
htmls[0].each_with_index do |html,i|
element = element.gsub(html,htmls[1][i])
end
end
item.each do |key,value|
if !value.kind_of?(Array)
value = value.nil? ? "" : value
element = element.gsub("{{#{key}}}",value)
element = element.gsub("%7B%7B#{key}%7D%7D",value)
end
end
html_to_render = html_to_render + element
end
temp = el.to_s
oldhtml << temp
temp = temp.gsub(el.inner_html, html_to_render)
newhtml << temp
end
end
[oldhtml,newhtml]
end
if params[:target_action] == "index"
file = File.open(File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', params[:target_controller].singularize, "#{params[:target_action]}.html.erb"))
doc = Nokogiri::HTML(file, nil, "UTF-8")
file.close
wrap_elements = doc.css("*[data-repeat]")
controller = "#{params[:target_controller].capitalize}_controller".classify.constantize.new
data = controller.send("#{params[:target_action]}")
keys = data.keys
wrap_elements.each do |wrap_element|
html_to_render = ""
(data[keys[0]].kind_of?(Array) ? data[keys[0]] : data[keys[1]]).each do |item|
el = wrap_element.inner_html
item.each do |key,value|
value = value.nil? ? "" : value
el = el.gsub("{{#{key}}}",value)
el = el.gsub("%7B%7B#{key}%7D%7D",value)
wrap_elements = doc.css("*[data-list][data-level='0']")
htmls = parsing_repeats_again(wrap_elements,data,1)
html = doc.to_s
htmls[0].each_with_index do |h,i|
html = html.gsub(h,htmls[1][i])
end
html_to_render = html_to_render + el
end
wrap_element.inner_html = html_to_render
end
html = doc.to_html
if keys[1]
(data[keys[1]].kind_of?(Array) ? data[keys[0]] : data[keys[1]]).each do |key,value|
value = value.nil? ? "" : value
@ -126,7 +154,7 @@ module ApplicationHelper
file.close
doc.to_html.html_safe
else
wrap_elements = doc.css("*[data-repeat-content]")
wrap_elements = doc.css("*[data-list][data-level='0']")
if wrap_elements.count == 0
wrap_element_html = doc.to_s
@ -143,21 +171,11 @@ module ApplicationHelper
data.keys.each do |key|
not_array_key = key if data["#{key}"].kind_of?(Hash)
end
wrap_elements.each do |wrap_element|
html_to_render = ""
content_array = wrap_element.attr("data-repeat-content")
data["#{content_array}"].each do |item|
el = wrap_element.inner_html
item.each do |key,value|
value = value.nil? ? "" : value
el = el.gsub("{{#{key}}}",value)
el = el.gsub("%7B%7B#{key}%7D%7D",value)
htmls = parsing_repeats_again(wrap_elements,data,1)
html = doc.to_s
htmls[0].each_with_index do |h,i|
html = html.gsub(h,htmls[1][i])
end
html_to_render = html_to_render + el
end
wrap_element.inner_html = html_to_render
end
html = doc.to_html
if data["#{not_array_key}"]
data["#{not_array_key}"].each do |key,value|
value = value.nil? ? "" : value
@ -169,6 +187,7 @@ module ApplicationHelper
end
end
end
end
def action_data

View File

@ -79,6 +79,7 @@ module OrbitBackendHelper
params[:filters][field].include?(value.to_s) ? "active" : "" rescue ""
end
def select_category(f, module_app)
render :partial => '/admin/categories/select_form', :locals => {:f=> f, :module_app=>module_app, :categories=>module_app.categories.enabled }
end
@ -87,6 +88,10 @@ module OrbitBackendHelper
render :partial => '/admin/tags/tag_form', :locals => {:f=> f, :module_app=>module_app, :tags=>module_app.tags }
end
def render_filter(fields)
render :partial => "shared/filter", :locals =>{:fields => fields}
end
end
module Orbit::FormBuilder

View File

@ -19,6 +19,13 @@ module OrbitHelper
@categories
end
def self.this_module_app
@module_app
end
def self.set_this_module_app(module_app)
@module_app = ModuleApp.where(:key=>module_app).first
end
def self.params
@params
end

View File

@ -1,8 +1,8 @@
<h2 class="widget-title">{{widget-title}}</h2>
<ul class="media-list index" module="announcement" data-repeat="4" data-module="announcement">
<ul class="media-list index" module="announcement" data-repeat="4" data-level="0" data-list="announcements">
<li class="media">
<a class="pull-left" href="{{link_to_show}}">
<img class="media-object" src="http://placehold.it/100x100">
<img class="media-object" src="{{img_src}}">
</a>
<div class="media-body">
<h4 class="media-heading"><a href="{{link_to_show}}">{{title}}</a></h4>

View File

@ -5,7 +5,7 @@
<small class="post-meta-date">
<span>
TAGS :
<span class="post-related" data-repeat-content="tags">
<span class="post-related" data-list="tags" data-level="0">
<a href="#"><span class="label label-info">{{tag}}</span></a>
</span>
</span>
@ -17,10 +17,10 @@
<p class="pic"><img src="{{image}}" alt=""></p>
<p>{{body}}</p>
</section>
<div class="post-related" data-repeat-content="bulletin_files">
<div class="post-related" data-list="bulletin_files" data-level="0">
<a href="{{file_url}}">{{file_title}}</a><br/>
</div>
<div class="post-related" data-repeat-content="bulletin_links">
<div class="post-related" data-list="bulletin_links" data-level="0">
<a href="{{link_url}}" target="_blank">{{link_title}}</a><br/>
</div>
</article>

View File

@ -1,52 +1,26 @@
<div class="index" module="archive">
<h2 class="widget-title">{{widget-title}}</h2>
<div class="list-group">
<div class="list-group-item">
<h4 class="list-group-item-heading">{{title}}</h4>
<div class="list-group-item" data-list="categories" data-level="0">
<h4 class="list-group-item-heading">{{category-title}}</h4>
<ul class="list-group-item-text">
<li data-list="archives" data-level="1">
<h5 class="archives-title">
{{archive-title}}
<span data-list="status" data-level="2">
<span class="label label-primary">{{archive-status}}</span>
</span>
</h5>
<ol class="archives-item" data-list="files" data-level="2">
<li>
<h5 class="archives-title">Service Updates</h5>
<ol class="archives-item">
<li>
<a href="#" class="archives-file" target="_blank" title="Evaluation Rules">Evaluation Rules</a>
<span class="label label-primary">pdf</span>
</li>
<li>
<a href="#" class="archives-file" target="_blank" title="Evaluation Rules">Evaluation Rules</a>
<span class="label label-primary">pdf</span>
<a href="{{file-url}}" class="archives-file" target="_blank" title="Evaluation Rules">{{file-name}}</a>
<span class="label label-primary">{{file-type}}</span>
</li>
</ol>
</li>
<li><h5 class="archives-title">Help Desk</h5></li>
<li><h5 class="archives-title">Validate License</h5></li>
<li><h5 class="archives-title">Privacy Policy</h5></li>
</ul>
</div>
<div class="list-group-item">
<h4 class="list-group-item-heading">{{title}}</h4>
<ul class="list-group-item-text">
<li><h5 class="archives-title">Service Updates</h5></li>
<li><h5 class="archives-title">Help Desk</h5></li>
<li><h5 class="archives-title">Validate License</h5></li>
<li><h5 class="archives-title">Privacy Policy</h5></li>
</ul>
</div>
<div class="list-group-item">
<h4 class="list-group-item-heading">{{title}}</h4>
<ul class="list-group-item-text">
<li><h5 class="archives-title">Service Updates</h5></li>
<li><h5 class="archives-title">Help Desk</h5></li>
<li><h5 class="archives-title">Validate License</h5></li>
<li><h5 class="archives-title">Privacy Policy</h5></li>
</ul>
</div>
<div class="list-group-item">
<h4 class="list-group-item-heading">{{title}}</h4>
<ul class="list-group-item-text">
<li><h5 class="archives-title">Service Updates</h5></li>
<li><h5 class="archives-title">Help Desk</h5></li>
<li><h5 class="archives-title">Validate License</h5></li>
<li><h5 class="archives-title">Privacy Policy</h5></li>
<li data-list="cool" data-level="1">
<span>This is for test</span>
</li>
</ul>
</div>
</div>

View File

@ -1,5 +1,5 @@
<h2 class="widget-title">{{widget-title}}</h2>
<ul class="media-list index" module="faq" data-repeat="4" data-module="faq">
<ul class="media-list index" module="faq" data-repeat="4" data-list="data" data-level="0">
<li class="media">
<div class="media-body">
<h4 class="media-heading"><a href="{{link_to_show}}">{{question}}</a></h4>

View File

@ -5,10 +5,10 @@
<section class="post">
<p>{{answer}}</p>
</section>
<div class="post-related" data-repeat-content="faqs_files">
<div class="post-related" data-list="faqs_files" data-level="0">
<a href="{{file_url}}" target="_blank">{{file_title}}</a><br/>
</div>
<div class="post-related" data-repeat-content="faqs_links">
<div class="post-related" data-list="faqs_links" data-level="0">
<a href="{{link_url}}" target="_blank">{{link_title}}</a><br/>
</div>
</article>

View File

@ -1,9 +1,9 @@
<div class="index" module="gallery">
<h2 class="widget-title">{{widget-title}}</h2>
<ul class="row" data-repeat="">
<ul class="row" data-list="data" data-level="0">
<li class="col-md-3 col-sm-4 col-xs-3">
<a href="{{link_to_show}}">
<img class="img-rounded" src="{{thumb-src}}" alt="">
<img class="img-rounded" src="{{thumb-src}}" width="200px" height="200px" alt="">
</a>
<h4 class="album-name">{{album-name}}</h4>
</li>

View File

@ -1,6 +1,6 @@
<div class="index" module="gallery">
<h2 class="widget-title">{{album-title}}</h2>
<ul class="row" data-repeat-content="images">
<ul class="row" data-list="images" data-level="0">
<li class="col-md-3 col-sm-4 col-xs-3">
<a href="{{link_to_show}}">
<img class="img-rounded" src="{{thumb-src}}" alt="">

View File

@ -1,6 +1,6 @@
<div class="index" module="web_link">
<h2 class="widget-title">{{widget-title}}</h2>
<div class="link-list" module="web_link" data-repeat="4" data-module="web_link">
<div class="link-list" module="web_link" data-repeat="4" data-list="web_link">
<ul class="link-list" module="web_link">
<li class="item">
<span class="title"><a href="{{link_to_show}}">{{title}}</a></span>

View File

@ -12,9 +12,9 @@
<div class="item-title">
<%= content_tag(:em, node.url, class: "muted") if node.class.to_s.eql?('Link') %>
<% if node.class.to_s.eql?('Page') %>
<%= link_to node.name, node.url %>
<%= link_to node.name, "/" + I18n.locale.to_s + node.url %>
<% else %>
<%= link_to node.title, node.url %>
<%= link_to node.title, "/" + I18n.locale.to_s + node.url %>
<% end %>
<div class="item-menu">
<%= link_to content_tag(:i, nil, class: "icon-eye-open"), pages_edit_view_path(:id => node.id.to_s), class: "view-page open-slide tip", title: "View", data: {title: node.name} if node.class.to_s.eql?('Page') %>

View File

@ -0,0 +1,73 @@
<% content_for :right_nav do %>
<ul class="nav nav-pills filter-nav pull-right">
<% fields.keys.each do |field| %>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-<%= field %>" data-toggle="collapse" data-parent="#filter" class="accordion-toggle"><%= t(field) %></a>
</div>
</li>
<% end %>
</ul>
<div class="filter-group accordion-group">
<% fields.keys.each do |field| %>
<div class="accordion-body collapse" id="collapse-<%= field %>">
<div class="accordion-inner pagination-right" data-toggle="buttons-checkbox">
<% fields[field].each do |val| %>
<%= link_to t(val[:title]), "#", :onclick => "filter.addFilter('filters[#{field}][]=#{val[:id]}')", :class => "btn btn-small #{is_filter_active?(field, val[:id])}" %>
<% end %>
</div>
<div class="filter-clear">
<a href="" class="btn btn-link btn-small"><i class="icons-cycle"></i> <%= t(:clear) %></a>
</div>
</div>
<% end %>
</div>
<% end %>
<script type="text/javascript">
var Filter = function(){
var makeFilters = function(){
return (window.location.search ? window.location.search.replace('?','').split('&') : []);
}
var filters = makeFilters(),
dom = null,
mainUrl = window.location.pathname;
this.init = function(d){
dom = $(d);
}
var updateTable = function(url){
xurl = (url == null ? ( filters.length ? mainUrl + "?" + filters.join('&') : mainUrl ) : null);
$.ajax({
url : xurl,
type : "get",
dataType : "html"
}).done(function(data){
history.pushState(null, null, decodeURIComponent(xurl));
filters = makeFilters();
dom.html(data);
$(".pagination a").click(function(){
updateTable($(this).attr('href'));
return false;
});
})
}
this.addFilter = function(filter){
$.each(filters,function(idx,data){
if(data.indexOf("page=")>-1) filters.splice(idx,1);
});
if( (index = filters.indexOf(filter) ) > -1){
mainUrl = mainUrl.replace(filter,'');
filters.splice(index,1);
}else{
filters.push(filter);
}
updateTable();
return false;
};
}
var filter = new Filter();
</script>

View File

@ -1,5 +1,6 @@
gem 'announcement', git: 'git@gitlab.tp.rulingcom.com:saurabh/announcement-test.git'
gem 'ad_banner', git: 'git@gitlab.tp.rulingcom.com:saurabh/adbanner-test.git'
gem "archive", git: 'git@gitlab.tp.rulingcom.com:saurabh/archive.git'
gem 'gallery', git: 'git@gitlab.tp.rulingcom.com:saurabh/gallery.git'
gem 'links', git: 'git@gitlab.tp.rulingcom.com:saurabh/links.git'
gem 'page_content', git: 'git@gitlab.tp.rulingcom.com:saurabh/pagecontent.git'

View File

@ -19,6 +19,14 @@ module OrbitModel
self.is_hidden
end
def statuses
statuses = []
statuses << I18n.t(:top) if is_top?
statuses << I18n.t(:hot) if is_hot?
statuses << I18n.t(:hidden) if is_hidden?
statuses
end
def status_for_table
status = ""
status << "<span class='label label-success'>#{I18n.t(:top)}</span> " if self.is_top