diff --git a/app/assets/images/slideshow_preview_A.png b/app/assets/images/slideshow_preview_A.png new file mode 100644 index 0000000..25a42a3 Binary files /dev/null and b/app/assets/images/slideshow_preview_A.png differ diff --git a/app/assets/images/slideshow_preview_B.png b/app/assets/images/slideshow_preview_B.png new file mode 100644 index 0000000..1d40e65 Binary files /dev/null and b/app/assets/images/slideshow_preview_B.png differ diff --git a/app/assets/javascripts/ad_banner/.keep b/app/assets/javascripts/ad_banner/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/app/assets/javascripts/ad_banner/banner_preview.js b/app/assets/javascripts/ad_banner/banner_preview.js new file mode 100644 index 0000000..7f59d8e --- /dev/null +++ b/app/assets/javascripts/ad_banner/banner_preview.js @@ -0,0 +1,82 @@ +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(); +}); + diff --git a/app/assets/javascripts/ad_banners.js b/app/assets/javascripts/ad_banners.js deleted file mode 100644 index dee720f..0000000 --- a/app/assets/javascripts/ad_banners.js +++ /dev/null @@ -1,2 +0,0 @@ -// Place all the behaviors and hooks related to the matching controller here. -// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/admin/ad_banners.js b/app/assets/javascripts/admin/ad_banners.js index dee720f..d059265 100644 --- a/app/assets/javascripts/admin/ad_banners.js +++ b/app/assets/javascripts/admin/ad_banners.js @@ -1,2 +1,21 @@ -// Place all the behaviors and hooks related to the matching controller here. -// All this logic will automatically be available in application.js. +$(function() { + $.pageslide.closeCallback(function(pageslide, item) { + $("tr").removeClass("active"); + pageslide.find('.preview').cycle('destroy'); + }); + $.pageslide.loadComplete(function(pageslide, item) { + $("tr").removeClass("active"); + item.closest('tr').addClass('active'); + if(item.data('id') == 'new') { + resetForm(); + pageslide.find('form').attr('action', '/admin/ad_banners/'); + pageslide.find('form').attr('method', 'post'); + } + else { + setForm(item.data('form')); + pageslide.find('form').attr('action', '/admin/ad_banners/' + item.data('id')); + pageslide.find('form').attr('method', 'put'); + } + setSlideshow(pageslide.find('.preview'), item.data()); + }); +}) \ No newline at end of file diff --git a/app/assets/javascripts/admin/ad_images.js b/app/assets/javascripts/admin/ad_images.js deleted file mode 100644 index dee720f..0000000 --- a/app/assets/javascripts/admin/ad_images.js +++ /dev/null @@ -1,2 +0,0 @@ -// Place all the behaviors and hooks related to the matching controller here. -// All this logic will automatically be available in application.js. diff --git a/app/assets/javascripts/cycle2.js b/app/assets/javascripts/cycle2.js new file mode 100644 index 0000000..60bea42 --- /dev/null +++ b/app/assets/javascripts/cycle2.js @@ -0,0 +1,4 @@ +//= require cycle2/jquery.cycle2.min.js +//= require cycle2/transition/jquery.cycle2.flip.min.js +//= require cycle2/transition/jquery.cycle2.scrollVert.min.js +//= require cycle2/transition/jquery.cycle2.tile.min.js \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/jquery.cycle2.min.js b/app/assets/javascripts/cycle2/jquery.cycle2.min.js new file mode 100644 index 0000000..9f9ec0f --- /dev/null +++ b/app/assets/javascripts/cycle2/jquery.cycle2.min.js @@ -0,0 +1,17 @@ +/*! +* jQuery Cycle2; build: v20131005 +* http://jquery.malsup.com/cycle2/ +* Copyright (c) 2013 M. Alsup; Dual licensed: MIT/GPL +*/ +/*! core engine; version: 20131003 */ +(function(e){"use strict";function t(e){return(e||"").toLowerCase()}var i="20131003";e.fn.cycle=function(i){var n;return 0!==this.length||e.isReady?this.each(function(){var n,s,o,c,r=e(this),l=e.fn.cycle.log;if(!r.data("cycle.opts")){(r.data("cycle-log")===!1||i&&i.log===!1||s&&s.log===!1)&&(l=e.noop),l("--c2 init--"),n=r.data();for(var a in n)n.hasOwnProperty(a)&&/^cycle[A-Z]+/.test(a)&&(c=n[a],o=a.match(/^cycle(.*)/)[1].replace(/^[A-Z]/,t),l(o+":",c,"("+typeof c+")"),n[o]=c);s=e.extend({},e.fn.cycle.defaults,n,i||{}),s.timeoutId=0,s.paused=s.paused||!1,s.container=r,s._maxZ=s.maxZ,s.API=e.extend({_container:r},e.fn.cycle.API),s.API.log=l,s.API.trigger=function(e,t){return s.container.trigger(e,t),s.API},r.data("cycle.opts",s),r.data("cycle.API",s.API),s.API.trigger("cycle-bootstrap",[s,s.API]),s.API.addInitialSlides(),s.API.preInitSlideshow(),s.slides.length&&s.API.initSlideshow()}}):(n={s:this.selector,c:this.context},e.fn.cycle.log("requeuing slideshow (dom not ready)"),e(function(){e(n.s,n.c).cycle(i)}),this)},e.fn.cycle.API={opts:function(){return this._container.data("cycle.opts")},addInitialSlides:function(){var t=this.opts(),i=t.slides;t.slideCount=0,t.slides=e(),i=i.jquery?i:t.container.find(i),t.random&&i.sort(function(){return Math.random()-.5}),t.API.add(i)},preInitSlideshow:function(){var t=this.opts();t.API.trigger("cycle-pre-initialize",[t]);var i=e.fn.cycle.transitions[t.fx];i&&e.isFunction(i.preInit)&&i.preInit(t),t._preInitialized=!0},postInitSlideshow:function(){var t=this.opts();t.API.trigger("cycle-post-initialize",[t]);var i=e.fn.cycle.transitions[t.fx];i&&e.isFunction(i.postInit)&&i.postInit(t)},initSlideshow:function(){var t,i=this.opts(),n=i.container;i.API.calcFirstSlide(),"static"==i.container.css("position")&&i.container.css("position","relative"),e(i.slides[i.currSlide]).css("opacity",1).show(),i.API.stackSlides(i.slides[i.currSlide],i.slides[i.nextSlide],!i.reverse),i.pauseOnHover&&(i.pauseOnHover!==!0&&(n=e(i.pauseOnHover)),n.hover(function(){i.API.pause(!0)},function(){i.API.resume(!0)})),i.timeout&&(t=i.API.getSlideOpts(i.currSlide),i.API.queueTransition(t,t.timeout+i.delay)),i._initialized=!0,i.API.updateView(!0),i.API.trigger("cycle-initialized",[i]),i.API.postInitSlideshow()},pause:function(t){var i=this.opts(),n=i.API.getSlideOpts(),s=i.hoverPaused||i.paused;t?i.hoverPaused=!0:i.paused=!0,s||(i.container.addClass("cycle-paused"),i.API.trigger("cycle-paused",[i]).log("cycle-paused"),n.timeout&&(clearTimeout(i.timeoutId),i.timeoutId=0,i._remainingTimeout-=e.now()-i._lastQueue,(0>i._remainingTimeout||isNaN(i._remainingTimeout))&&(i._remainingTimeout=void 0)))},resume:function(e){var t=this.opts(),i=!t.hoverPaused&&!t.paused;e?t.hoverPaused=!1:t.paused=!1,i||(t.container.removeClass("cycle-paused"),0===t.slides.filter(":animated").length&&t.API.queueTransition(t.API.getSlideOpts(),t._remainingTimeout),t.API.trigger("cycle-resumed",[t,t._remainingTimeout]).log("cycle-resumed"))},add:function(t,i){var n,s=this.opts(),o=s.slideCount,c=!1;"string"==e.type(t)&&(t=e.trim(t)),e(t).each(function(){var t,n=e(this);i?s.container.prepend(n):s.container.append(n),s.slideCount++,t=s.API.buildSlideOpts(n),s.slides=i?e(n).add(s.slides):s.slides.add(n),s.API.initSlide(t,n,--s._maxZ),n.data("cycle.opts",t),s.API.trigger("cycle-slide-added",[s,t,n])}),s.API.updateView(!0),c=s._preInitialized&&2>o&&s.slideCount>=1,c&&(s._initialized?s.timeout&&(n=s.slides.length,s.nextSlide=s.reverse?n-1:1,s.timeoutId||s.API.queueTransition(s)):s.API.initSlideshow())},calcFirstSlide:function(){var e,t=this.opts();e=parseInt(t.startingSlide||0,10),(e>=t.slides.length||0>e)&&(e=0),t.currSlide=e,t.reverse?(t.nextSlide=e-1,0>t.nextSlide&&(t.nextSlide=t.slides.length-1)):(t.nextSlide=e+1,t.nextSlide==t.slides.length&&(t.nextSlide=0))},calcNextSlide:function(){var e,t=this.opts();t.reverse?(e=0>t.nextSlide-1,t.nextSlide=e?t.slideCount-1:t.nextSlide-1,t.currSlide=e?0:t.nextSlide+1):(e=t.nextSlide+1==t.slides.length,t.nextSlide=e?0:t.nextSlide+1,t.currSlide=e?t.slides.length-1:t.nextSlide-1)},calcTx:function(t,i){var n,s=t;return i&&s.manualFx&&(n=e.fn.cycle.transitions[s.manualFx]),n||(n=e.fn.cycle.transitions[s.fx]),n||(n=e.fn.cycle.transitions.fade,s.API.log('Transition "'+s.fx+'" not found. Using fade.')),n},prepareTx:function(e,t){var i,n,s,o,c,r=this.opts();return 2>r.slideCount?(r.timeoutId=0,void 0):(!e||r.busy&&!r.manualTrump||(r.API.stopTransition(),r.busy=!1,clearTimeout(r.timeoutId),r.timeoutId=0),r.busy||(0!==r.timeoutId||e)&&(n=r.slides[r.currSlide],s=r.slides[r.nextSlide],o=r.API.getSlideOpts(r.nextSlide),c=r.API.calcTx(o,e),r._tx=c,e&&void 0!==o.manualSpeed&&(o.speed=o.manualSpeed),r.nextSlide!=r.currSlide&&(e||!r.paused&&!r.hoverPaused&&r.timeout)?(r.API.trigger("cycle-before",[o,n,s,t]),c.before&&c.before(o,n,s,t),i=function(){r.busy=!1,r.container.data("cycle.opts")&&(c.after&&c.after(o,n,s,t),r.API.trigger("cycle-after",[o,n,s,t]),r.API.queueTransition(o),r.API.updateView(!0))},r.busy=!0,c.transition?c.transition(o,n,s,t,i):r.API.doTransition(o,n,s,t,i),r.API.calcNextSlide(),r.API.updateView()):r.API.queueTransition(o)),void 0)},doTransition:function(t,i,n,s,o){var c=t,r=e(i),l=e(n),a=function(){l.animate(c.animIn||{opacity:1},c.speed,c.easeIn||c.easing,o)};l.css(c.cssBefore||{}),r.animate(c.animOut||{},c.speed,c.easeOut||c.easing,function(){r.css(c.cssAfter||{}),c.sync||a()}),c.sync&&a()},queueTransition:function(t,i){var n=this.opts(),s=void 0!==i?i:t.timeout;return 0===n.nextSlide&&0===--n.loop?(n.API.log("terminating; loop=0"),n.timeout=0,s?setTimeout(function(){n.API.trigger("cycle-finished",[n])},s):n.API.trigger("cycle-finished",[n]),n.nextSlide=n.currSlide,void 0):(s&&(n._lastQueue=e.now(),void 0===i&&(n._remainingTimeout=t.timeout),n.paused||n.hoverPaused||(n.timeoutId=setTimeout(function(){n.API.prepareTx(!1,!n.reverse)},s))),void 0)},stopTransition:function(){var e=this.opts();e.slides.filter(":animated").length&&(e.slides.stop(!1,!0),e.API.trigger("cycle-transition-stopped",[e])),e._tx&&e._tx.stopTransition&&e._tx.stopTransition(e)},advanceSlide:function(e){var t=this.opts();return clearTimeout(t.timeoutId),t.timeoutId=0,t.nextSlide=t.currSlide+e,0>t.nextSlide?t.nextSlide=t.slides.length-1:t.nextSlide>=t.slides.length&&(t.nextSlide=0),t.API.prepareTx(!0,e>=0),!1},buildSlideOpts:function(i){var n,s,o=this.opts(),c=i.data()||{};for(var r in c)c.hasOwnProperty(r)&&/^cycle[A-Z]+/.test(r)&&(n=c[r],s=r.match(/^cycle(.*)/)[1].replace(/^[A-Z]/,t),o.API.log("["+(o.slideCount-1)+"]",s+":",n,"("+typeof n+")"),c[s]=n);c=e.extend({},e.fn.cycle.defaults,o,c),c.slideNum=o.slideCount;try{delete c.API,delete c.slideCount,delete c.currSlide,delete c.nextSlide,delete c.slides}catch(l){}return c},getSlideOpts:function(t){var i=this.opts();void 0===t&&(t=i.currSlide);var n=i.slides[t],s=e(n).data("cycle.opts");return e.extend({},i,s)},initSlide:function(t,i,n){var s=this.opts();i.css(t.slideCss||{}),n>0&&i.css("zIndex",n),isNaN(t.speed)&&(t.speed=e.fx.speeds[t.speed]||e.fx.speeds._default),t.sync||(t.speed=t.speed/2),i.addClass(s.slideClass)},updateView:function(e,t){var i=this.opts();if(i._initialized){var n=i.API.getSlideOpts(),s=i.slides[i.currSlide];!e&&t!==!0&&(i.API.trigger("cycle-update-view-before",[i,n,s]),0>i.updateView)||(i.slideActiveClass&&i.slides.removeClass(i.slideActiveClass).eq(i.currSlide).addClass(i.slideActiveClass),e&&i.hideNonActive&&i.slides.filter(":not(."+i.slideActiveClass+")").hide(),i.API.trigger("cycle-update-view",[i,n,s,e]),e&&i.API.trigger("cycle-update-view-after",[i,n,s]))}},getComponent:function(t){var i=this.opts(),n=i[t];return"string"==typeof n?/^\s*[\>|\+|~]/.test(n)?i.container.find(n):e(n):n.jquery?n:e(n)},stackSlides:function(t,i,n){var s=this.opts();t||(t=s.slides[s.currSlide],i=s.slides[s.nextSlide],n=!s.reverse),e(t).css("zIndex",s.maxZ);var o,c=s.maxZ-2,r=s.slideCount;if(n){for(o=s.currSlide+1;r>o;o++)e(s.slides[o]).css("zIndex",c--);for(o=0;s.currSlide>o;o++)e(s.slides[o]).css("zIndex",c--)}else{for(o=s.currSlide-1;o>=0;o--)e(s.slides[o]).css("zIndex",c--);for(o=r-1;o>s.currSlide;o--)e(s.slides[o]).css("zIndex",c--)}e(i).css("zIndex",s.maxZ-1)},getSlideIndex:function(e){return this.opts().slides.index(e)}},e.fn.cycle.log=function(){window.console&&console.log&&console.log("[cycle2] "+Array.prototype.join.call(arguments," "))},e.fn.cycle.version=function(){return"Cycle2: "+i},e.fn.cycle.transitions={custom:{},none:{before:function(e,t,i,n){e.API.stackSlides(i,t,n),e.cssBefore={opacity:1,display:"block"}}},fade:{before:function(t,i,n,s){var o=t.API.getSlideOpts(t.nextSlide).slideCss||{};t.API.stackSlides(i,n,s),t.cssBefore=e.extend(o,{opacity:0,display:"block"}),t.animIn={opacity:1},t.animOut={opacity:0}}},fadeout:{before:function(t,i,n,s){var o=t.API.getSlideOpts(t.nextSlide).slideCss||{};t.API.stackSlides(i,n,s),t.cssBefore=e.extend(o,{opacity:1,display:"block"}),t.animOut={opacity:0}}},scrollHorz:{before:function(e,t,i,n){e.API.stackSlides(t,i,n);var s=e.container.css("overflow","hidden").width();e.cssBefore={left:n?s:-s,top:0,opacity:1,display:"block"},e.cssAfter={zIndex:e._maxZ-2,left:0},e.animIn={left:0},e.animOut={left:n?-s:s}}}},e.fn.cycle.defaults={allowWrap:!0,autoSelector:".cycle-slideshow[data-cycle-auto-init!=false]",delay:0,easing:null,fx:"fade",hideNonActive:!0,loop:0,manualFx:void 0,manualSpeed:void 0,manualTrump:!0,maxZ:100,pauseOnHover:!1,reverse:!1,slideActiveClass:"cycle-slide-active",slideClass:"cycle-slide",slideCss:{position:"absolute",top:0,left:0},slides:"> img",speed:500,startingSlide:0,sync:!0,timeout:4e3,updateView:-1},e(document).ready(function(){e(e.fn.cycle.defaults.autoSelector).cycle()})})(jQuery),/*! Cycle2 autoheight plugin; Copyright (c) M.Alsup, 2012; version: 20130304 */ +function(e){"use strict";function t(t,n){var s,o,c,r=n.autoHeight;if("container"==r)o=e(n.slides[n.currSlide]).outerHeight(),n.container.height(o);else if(n._autoHeightRatio)n.container.height(n.container.width()/n._autoHeightRatio);else if("calc"===r||"number"==e.type(r)&&r>=0){if(c="calc"===r?i(t,n):r>=n.slides.length?0:r,c==n._sentinelIndex)return;n._sentinelIndex=c,n._sentinel&&n._sentinel.remove(),s=e(n.slides[c].cloneNode(!0)),s.removeAttr("id name rel").find("[id],[name],[rel]").removeAttr("id name rel"),s.css({position:"static",visibility:"hidden",display:"block"}).prependTo(n.container).addClass("cycle-sentinel cycle-slide").removeClass("cycle-slide-active"),s.find("*").css("visibility","hidden"),n._sentinel=s}}function i(t,i){var n=0,s=-1;return i.slides.each(function(t){var i=e(this).height();i>s&&(s=i,n=t)}),n}function n(t,i,n,s){var o=e(s).outerHeight(),c=i.sync?i.speed/2:i.speed;i.container.animate({height:o},c)}function s(i,o){o._autoHeightOnResize&&(e(window).off("resize orientationchange",o._autoHeightOnResize),o._autoHeightOnResize=null),o.container.off("cycle-slide-added cycle-slide-removed",t),o.container.off("cycle-destroyed",s),o.container.off("cycle-before",n),o._sentinel&&(o._sentinel.remove(),o._sentinel=null)}e.extend(e.fn.cycle.defaults,{autoHeight:0}),e(document).on("cycle-initialized",function(i,o){function c(){t(i,o)}var r,l=o.autoHeight,a=e.type(l),d=null;("string"===a||"number"===a)&&(o.container.on("cycle-slide-added cycle-slide-removed",t),o.container.on("cycle-destroyed",s),"container"==l?o.container.on("cycle-before",n):"string"===a&&/\d+\:\d+/.test(l)&&(r=l.match(/(\d+)\:(\d+)/),r=r[1]/r[2],o._autoHeightRatio=r),"number"!==a&&(o._autoHeightOnResize=function(){clearTimeout(d),d=setTimeout(c,50)},e(window).on("resize orientationchange",o._autoHeightOnResize)),setTimeout(c,30))})}(jQuery),/*! caption plugin for Cycle2; version: 20130306 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{caption:"> .cycle-caption",captionTemplate:"{{slideNum}} / {{slideCount}}",overlay:"> .cycle-overlay",overlayTemplate:"
{{title}}
{{desc}}
",captionModule:"caption"}),e(document).on("cycle-update-view",function(t,i,n,s){"caption"===i.captionModule&&e.each(["caption","overlay"],function(){var e=this,t=n[e+"Template"],o=i.API.getComponent(e);o.length&&t?(o.html(i.API.tmpl(t,n,i,s)),o.show()):o.hide()})}),e(document).on("cycle-destroyed",function(t,i){var n;e.each(["caption","overlay"],function(){var e=this,t=i[e+"Template"];i[e]&&t&&(n=i.API.getComponent("caption"),n.empty())})})}(jQuery),/*! command plugin for Cycle2; version: 20130707 */ +function(e){"use strict";var t=e.fn.cycle;e.fn.cycle=function(i){var n,s,o,c=e.makeArray(arguments);return"number"==e.type(i)?this.cycle("goto",i):"string"==e.type(i)?this.each(function(){var r;return n=i,o=e(this).data("cycle.opts"),void 0===o?(t.log('slideshow must be initialized before sending commands; "'+n+'" ignored'),void 0):(n="goto"==n?"jump":n,s=o.API[n],e.isFunction(s)?(r=e.makeArray(c),r.shift(),s.apply(o.API,r)):(t.log("unknown command: ",n),void 0))}):t.apply(this,arguments)},e.extend(e.fn.cycle,t),e.extend(t.API,{next:function(){var e=this.opts();if(!e.busy||e.manualTrump){var t=e.reverse?-1:1;e.allowWrap===!1&&e.currSlide+t>=e.slideCount||(e.API.advanceSlide(t),e.API.trigger("cycle-next",[e]).log("cycle-next"))}},prev:function(){var e=this.opts();if(!e.busy||e.manualTrump){var t=e.reverse?1:-1;e.allowWrap===!1&&0>e.currSlide+t||(e.API.advanceSlide(t),e.API.trigger("cycle-prev",[e]).log("cycle-prev"))}},destroy:function(){this.stop();var t=this.opts(),i=e.isFunction(e._data)?e._data:e.noop;clearTimeout(t.timeoutId),t.timeoutId=0,t.API.stop(),t.API.trigger("cycle-destroyed",[t]).log("cycle-destroyed"),t.container.removeData(),i(t.container[0],"parsedAttrs",!1),t.retainStylesOnDestroy||(t.container.removeAttr("style"),t.slides.removeAttr("style"),t.slides.removeClass(t.slideActiveClass)),t.slides.each(function(){e(this).removeData(),i(this,"parsedAttrs",!1)})},jump:function(e){var t,i=this.opts();if(!i.busy||i.manualTrump){var n=parseInt(e,10);if(isNaN(n)||0>n||n>=i.slides.length)return i.API.log("goto: invalid slide index: "+n),void 0;if(n==i.currSlide)return i.API.log("goto: skipping, already on slide",n),void 0;i.nextSlide=n,clearTimeout(i.timeoutId),i.timeoutId=0,i.API.log("goto: ",n," (zero-index)"),t=i.currSlider;r++)i=s.slides[r],r==t?n=i:(o.push(i),e(i).data("cycle.opts").slideNum=c,c++);n&&(s.slides=e(o),s.slideCount--,e(n).remove(),t==s.currSlide?s.API.advanceSlide(1):s.currSlide>t?s.currSlide--:s.currSlide++,s.API.trigger("cycle-slide-removed",[s,t,n]).log("cycle-slide-removed"),s.API.updateView())}}),e(document).on("click.cycle","[data-cycle-cmd]",function(t){t.preventDefault();var i=e(this),n=i.data("cycle-cmd"),s=i.data("cycle-context")||".cycle-slideshow";e(s).cycle(n,i.data("cycle-arg"))})}(jQuery),/*! hash plugin for Cycle2; version: 20130905 */ +function(e){"use strict";function t(t,i){var n;return t._hashFence?(t._hashFence=!1,void 0):(n=window.location.hash.substring(1),t.slides.each(function(s){if(e(this).data("cycle-hash")==n){if(i===!0)t.startingSlide=s;else{var o=s>t.currSlide;t.nextSlide=s,t.API.prepareTx(!0,o)}return!1}}),void 0)}e(document).on("cycle-pre-initialize",function(i,n){t(n,!0),n._onHashChange=function(){t(n,!1)},e(window).on("hashchange",n._onHashChange)}),e(document).on("cycle-update-view",function(e,t,i){i.hash&&"#"+i.hash!=window.location.hash&&(t._hashFence=!0,window.location.hash=i.hash)}),e(document).on("cycle-destroyed",function(t,i){i._onHashChange&&e(window).off("hashchange",i._onHashChange)})}(jQuery),/*! loader plugin for Cycle2; version: 20130307 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{loader:!1}),e(document).on("cycle-bootstrap",function(t,i){function n(t,n){function o(t){var o;"wait"==i.loader?(r.push(t),0===a&&(r.sort(c),s.apply(i.API,[r,n]),i.container.removeClass("cycle-loading"))):(o=e(i.slides[i.currSlide]),s.apply(i.API,[t,n]),o.show(),i.container.removeClass("cycle-loading"))}function c(e,t){return e.data("index")-t.data("index")}var r=[];if("string"==e.type(t))t=e.trim(t);else if("array"===e.type(t))for(var l=0;t.length>l;l++)t[l]=e(t[l])[0];t=e(t);var a=t.length;a&&(t.hide().appendTo("body").each(function(t){function c(){0===--l&&(--a,o(d))}var l=0,d=e(this),u=d.is("img")?d:d.find("img");return d.data("index",t),u=u.filter(":not(.cycle-loader-ignore)").filter(':not([src=""])'),u.length?(l=u.length,u.each(function(){this.complete?c():e(this).load(function(){c()}).error(function(){0===--l&&(i.API.log("slide skipped; img not loaded:",this.src),0===--a&&"wait"==i.loader&&s.apply(i.API,[r,n]))})}),void 0):(--a,r.push(d),void 0)}),a&&i.container.addClass("cycle-loading"))}var s;i.loader&&(s=i.API.add,i.API.add=n)})}(jQuery),/*! pager plugin for Cycle2; version: 20130525 */ +function(e){"use strict";function t(t,i,n){var s,o=t.API.getComponent("pager");o.each(function(){var o=e(this);if(i.pagerTemplate){var c=t.API.tmpl(i.pagerTemplate,i,t,n[0]);s=e(c).appendTo(o)}else s=o.children().eq(t.slideCount-1);s.on(t.pagerEvent,function(e){e.preventDefault(),t.API.page(o,e.currentTarget)})})}function i(e,t){var i=this.opts();if(!i.busy||i.manualTrump){var n=e.children().index(t),s=n,o=s>i.currSlide;i.currSlide!=s&&(i.nextSlide=s,i.API.prepareTx(!0,o),i.API.trigger("cycle-pager-activated",[i,e,t]))}}e.extend(e.fn.cycle.defaults,{pager:"> .cycle-pager",pagerActiveClass:"cycle-pager-active",pagerEvent:"click.cycle",pagerTemplate:""}),e(document).on("cycle-bootstrap",function(e,i,n){n.buildPagerLink=t}),e(document).on("cycle-slide-added",function(e,t,n,s){t.pager&&(t.API.buildPagerLink(t,n,s),t.API.page=i)}),e(document).on("cycle-slide-removed",function(t,i,n){if(i.pager){var s=i.API.getComponent("pager");s.each(function(){var t=e(this);e(t.children()[n]).remove()})}}),e(document).on("cycle-update-view",function(t,i){var n;i.pager&&(n=i.API.getComponent("pager"),n.each(function(){e(this).children().removeClass(i.pagerActiveClass).eq(i.currSlide).addClass(i.pagerActiveClass)}))}),e(document).on("cycle-destroyed",function(e,t){var i=t.API.getComponent("pager");i&&(i.children().off(t.pagerEvent),t.pagerTemplate&&i.empty())})}(jQuery),/*! prevnext plugin for Cycle2; version: 20130709 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{next:"> .cycle-next",nextEvent:"click.cycle",disabledClass:"disabled",prev:"> .cycle-prev",prevEvent:"click.cycle",swipe:!1}),e(document).on("cycle-initialized",function(e,t){if(t.API.getComponent("next").on(t.nextEvent,function(e){e.preventDefault(),t.API.next()}),t.API.getComponent("prev").on(t.prevEvent,function(e){e.preventDefault(),t.API.prev()}),t.swipe){var i=t.swipeVert?"swipeUp.cycle":"swipeLeft.cycle swipeleft.cycle",n=t.swipeVert?"swipeDown.cycle":"swipeRight.cycle swiperight.cycle";t.container.on(i,function(){t.API.next()}),t.container.on(n,function(){t.API.prev()})}}),e(document).on("cycle-update-view",function(e,t){if(!t.allowWrap){var i=t.disabledClass,n=t.API.getComponent("next"),s=t.API.getComponent("prev"),o=t._prevBoundry||0,c=void 0!==t._nextBoundry?t._nextBoundry:t.slideCount-1;t.currSlide==c?n.addClass(i).prop("disabled",!0):n.removeClass(i).prop("disabled",!1),t.currSlide===o?s.addClass(i).prop("disabled",!0):s.removeClass(i).prop("disabled",!1)}}),e(document).on("cycle-destroyed",function(e,t){t.API.getComponent("prev").off(t.nextEvent),t.API.getComponent("next").off(t.prevEvent),t.container.off("swipeleft.cycle swiperight.cycle swipeLeft.cycle swipeRight.cycle swipeUp.cycle swipeDown.cycle")})}(jQuery),/*! progressive loader plugin for Cycle2; version: 20130315 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{progressive:!1}),e(document).on("cycle-pre-initialize",function(t,i){if(i.progressive){var n,s,o=i.API,c=o.next,r=o.prev,l=o.prepareTx,a=e.type(i.progressive);if("array"==a)n=i.progressive;else if(e.isFunction(i.progressive))n=i.progressive(i);else if("string"==a){if(s=e(i.progressive),n=e.trim(s.html()),!n)return;if(/^(\[)/.test(n))try{n=e.parseJSON(n)}catch(d){return o.log("error parsing progressive slides",d),void 0}else n=n.split(RegExp(s.data("cycle-split")||"\n")),n[n.length-1]||n.pop()}l&&(o.prepareTx=function(e,t){var s,o;return e||0===n.length?(l.apply(i.API,[e,t]),void 0):(t&&i.currSlide==i.slideCount-1?(o=n[0],n=n.slice(1),i.container.one("cycle-slide-added",function(e,t){setTimeout(function(){t.API.advanceSlide(1)},50)}),i.API.add(o)):t||0!==i.currSlide?l.apply(i.API,[e,t]):(s=n.length-1,o=n[s],n=n.slice(0,s),i.container.one("cycle-slide-added",function(e,t){setTimeout(function(){t.currSlide=1,t.API.advanceSlide(-1)},50)}),i.API.add(o,!0)),void 0)}),c&&(o.next=function(){var e=this.opts();if(n.length&&e.currSlide==e.slideCount-1){var t=n[0];n=n.slice(1),e.container.one("cycle-slide-added",function(e,t){c.apply(t.API),t.container.removeClass("cycle-loading")}),e.container.addClass("cycle-loading"),e.API.add(t)}else c.apply(e.API)}),r&&(o.prev=function(){var e=this.opts();if(n.length&&0===e.currSlide){var t=n.length-1,i=n[t];n=n.slice(0,t),e.container.one("cycle-slide-added",function(e,t){t.currSlide=1,t.API.advanceSlide(-1),t.container.removeClass("cycle-loading")}),e.container.addClass("cycle-loading"),e.API.add(i,!0)}else r.apply(e.API)})}})}(jQuery),/*! tmpl plugin for Cycle2; version: 20121227 */ +function(e){"use strict";e.extend(e.fn.cycle.defaults,{tmplRegex:"{{((.)?.*?)}}"}),e.extend(e.fn.cycle.API,{tmpl:function(t,i){var n=RegExp(i.tmplRegex||e.fn.cycle.defaults.tmplRegex,"g"),s=e.makeArray(arguments);return s.shift(),t.replace(n,function(t,i){var n,o,c,r,l=i.split(".");for(n=0;s.length>n;n++)if(c=s[n]){if(l.length>1)for(r=c,o=0;l.length>o;o++)c=r,r=r[l[o]]||i;else r=c[i];if(e.isFunction(r))return r.apply(c,s);if(void 0!==r&&null!==r&&r!=i)return r}return i})}})}(jQuery); +//@ sourceMappingURL=jquery.cycle2.js.map \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.flip.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.flip.min.js new file mode 100644 index 0000000..5b71b2c --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.flip.min.js @@ -0,0 +1,2 @@ +/* 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); \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.ie-fade.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.ie-fade.min.js new file mode 100644 index 0000000..89b50d2 --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.ie-fade.min.js @@ -0,0 +1,2 @@ +/*! 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); \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.scrollVert.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.scrollVert.min.js new file mode 100644 index 0000000..c5ebe28 --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.scrollVert.min.js @@ -0,0 +1,2 @@ +/*! 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); \ No newline at end of file diff --git a/app/assets/javascripts/cycle2/transition/jquery.cycle2.tile.min.js b/app/assets/javascripts/cycle2/transition/jquery.cycle2.tile.min.js new file mode 100644 index 0000000..f64379f --- /dev/null +++ b/app/assets/javascripts/cycle2/transition/jquery.cycle2.tile.min.js @@ -0,0 +1,2 @@ +/* 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('
');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("
").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); \ No newline at end of file diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index eca6896..79460b5 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -1,35 +1,56 @@ class Admin::AdBannersController < OrbitAdminController - def initialize - super - @app_title = "ad_banner" + def index + @banners = Banner.all.page(params[:page]).per(10) + @table_fields = ["Banner Name","Effect","Transition Interval","Transition Speed","Size","Preview"] end - - def index - @ad_banners = Banner.all - end - + def show - @ad_banners = Banner.all + @ad_banners = Banner.all @active = Banner.find(params[:id]) render :action => 'index' end - + def new - @ad_banner = Banner.new + @ad_banner = Banner.new + render layout: false end - + def create - @ad_banner = Banner.new(banner_params) - @ad_banner.save - render "index" + @ad_banner = Banner.new(banner_params) + if @ad_banner.save + redirect_to admin_ad_banners_url + else + @ad_banner = Banner.new(params[:ad_banner]) + render :new + end + end + + def edit + @ad_banner = Banner.find(params[:id]) + render layout: false + end + + def update + @ad_banner = Banner.find(params[:id]) + if @ad_banner.update_attributes(banner_params) + redirect_to admin_ad_banners_url, :status => 303 + else + render :edit + end end + def destroy + @ad_banner = Banner.find(params[:id]) + @ad_banner.destroy + redirect_to admin_ad_banners_url + end + private # Never trust parameters from the scary internet, only allow the white list through. def banner_params - params.require(:banner).permit(:ad_fx, :height, :speed, :title, :timeout, :width) + params.require(:ad_banner).permit! end end diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index cf0b9c1..fe4c082 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -1,23 +1,66 @@ class Admin::AdImagesController < Admin::AdBannersController + def initialize + super + @app_title = "ad_banner" + end + def index - @ad_images = AdImage.all + @ad_images = AdImage.all.page(params[:page]).per(10) + @table_fields = ["Preview","Banner","Title","Start Date","End Date", "Link"] end - def new - @ad_image = AdImage.new - @ad_banners = Banner.all + def edit + @ad_image = AdImage.find(params[:id]) + @ad_banners = Banner.all + @tags = @module_app.tags || [] end + + def update + @ad_image = AdImage.find(params[:id]) + if @ad_image.update_attributes(ad_image_params) + redirect_to admin_ad_images_url + else + @ad_banners = Banner.all + @tags = @module_app.tags || [] + render action: :edit + end + end + + def new + @ad_image = AdImage.new + @ad_banners = Banner.all + @tags = @module_app.tags || [] + @ad_image.postdate = Date.today + @ad_image.deadline = Date.today + 30 + end + def create - @ad_image = AdImage.new(ad_image_params) - @ad_image.save - redirect_to admin_ad_images_path + @ad_image = AdImage.new(ad_image_params) + if @ad_image.save + redirect_to admin_ad_images_url + else + @ad_banners = Banner.all + @tags = @module_app.tags || [] + @ad_image = AdImage.new(ad_image_params) + render action: :new + end + end + + def destroy + @ad_image = AdImage.find params[:id] + if @ad_image.destroy + redirect_to admin_ad_images_url + end end private - # Never trust parameters from the scary internet, only allow the white list through. def ad_image_params - params.require(:ad_image).permit(:weight, :out_link, :link_open, :file, :file_cache, :banner_id, title_translations: [:en, :zh_tw], context_translations: [:en, :zh_tw]) + params.require(:ad_image).permit! + end + + def setup_vars + @module_app = ModuleApp.where(:key => "ad_banner").first end end \ No newline at end of file diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index bb88b38..523c915 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -11,6 +11,8 @@ class AdImage field :weight, type: Integer, default: 1 field :out_link, type: String field :link_open, type: String + field :postdate , :type => DateTime, :default => Time.now + field :deadline , :type => DateTime LINK_OPEN_TYPES = ["local", "new_window"] belongs_to :banner diff --git a/app/models/banner.rb b/app/models/banner.rb index 6271148..af0cd63 100644 --- a/app/models/banner.rb +++ b/app/models/banner.rb @@ -25,4 +25,12 @@ class Banner def timeout_millisecond self.timeout*1000 rescue 0 end + + def preview_link + "Preview".html_safe + end + + def data_attribute_hash + {'width'=> self.width,'height'=> self.height,'ad_fx'=> self.ad_fx,'name'=>self.title,'timeout'=>self.timeout,'speed'=>self.speed}.to_json + end end diff --git a/app/views/admin/ad_banners/_form.html.erb b/app/views/admin/ad_banners/_form.html.erb new file mode 100644 index 0000000..b6fd0e3 --- /dev/null +++ b/app/views/admin/ad_banners/_form.html.erb @@ -0,0 +1,28 @@ +<%#= flash_messages %> +<%#= f.error_messages %> + +<%= f.label :title, t('ad_banner.banner_name') %> +<%= f.text_field :title, class: 'input-large', placeholder: t('ad_banner.banner_name'), id: 'name' %> +<%= t('ad_banner.name_only_english') %> + +<%= f.label :timeout, t('ad_banner.transition_interval') %> +<%= f.number_field :timeout, in: 0..60, step: 1, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'timeout' %> +<%= t('ad_banner.number_seconds') %> + +<%= f.label :speed, t('ad_banner.transition_speed') %> +<%= f.number_field :speed, in: 0..1000, step: 100, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'speed' %> +<%= t('ad_banner.number_milliseconds') %> + +<%= f.label :size, t('ad_banner.size') %> + +<%= f.number_field :width, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'width' %> + +<%= f.number_field :height, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'height' %> + +<%= f.label :ad_fx, t('ad_banner.effect') %> +<%= f.select :ad_fx, Banner::FX_TYPES, {}, {class: 'ad_banner_ad_fx', id: 'ad_fx'} %> +

<%= t('ad_banner.no_ie_10_effect_support') %>

+
+ <%= image_tag "slideshow_preview_A.png", width: 200, height: 80 %> + <%= image_tag "slideshow_preview_B.png", width: 200, height: 80 %> +
diff --git a/app/views/admin/ad_banners/_index.html.erb b/app/views/admin/ad_banners/_index.html.erb new file mode 100644 index 0000000..e2c71e2 --- /dev/null +++ b/app/views/admin/ad_banners/_index.html.erb @@ -0,0 +1,33 @@ + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + <% @banners.each do |banner| %> + + + + + + + + + <% end %> + +
+ <%= banner.title %> +
+ +
+
<%= banner.ad_fx %><%= banner.timeout %><%= banner.speed %><%= banner.size %><%= banner.preview_link %>
diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index 42475b2..383edb3 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -1,8 +1,54 @@ -<% @ad_banners.each do |a|%> - <%= a.title %> - <%= a.ad_fx %> - <%= a.height %> - <%= a.width %> - <%= a.speed %> -<% end %> \ No newline at end of file +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "cycle2" %> + <%= javascript_include_tag "ad_banner/banner_preview" %> +<% end %> + +
+ + +
+ + +
+
+ + + + +
+
+
+
+ <%= form_for :ad_banner, url: nil, remote: true do |f| %> +
+ <%= render :partial => "form", :locals => { :f => f } %> +
+ <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small' %> +
+
+ <% end %> +
+
+
+
\ No newline at end of file diff --git a/app/views/admin/ad_banners/index.js.erb b/app/views/admin/ad_banners/index.js.erb new file mode 100644 index 0000000..a5e1afa --- /dev/null +++ b/app/views/admin/ad_banners/index.js.erb @@ -0,0 +1,4 @@ +$("#banner_index").html("<%= j render 'index' %>") +$.pageslide.close(); +openSlide(); +preview(); \ No newline at end of file diff --git a/app/views/admin/ad_banners/new.html.erb b/app/views/admin/ad_banners/new.html.erb deleted file mode 100644 index f74435d..0000000 --- a/app/views/admin/ad_banners/new.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<%= form_for(@ad_banner, url: {action: "create"}) do |f| %> - Title <%= f.text_field :title %> - - Timeout <%= f.text_field :timeout %> - - Width <%= f.text_field :width %> - - Height <%= f.text_field :height %> - - Speed <%= f.text_field :speed %> - - Ad Fx <%= f.text_field :ad_fx %> - - <%= f.submit "Create Banner" %> -<% end %> diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb new file mode 100644 index 0000000..ea21b67 --- /dev/null +++ b/app/views/admin/ad_images/_form.html.erb @@ -0,0 +1,216 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + +<%#= f.error_messages %> + + +
+ + + + + + +
+ + +
+ + +
+ +
+ <%= f.select :banner_id, @ad_banners.collect{|t| [ t.title, t.id ]} %> +
+
+ + +
+ +
+ <%= f.datetime_picker :postdate, :no_label => true %> +
+
+ + +
+ +
+ <%= f.datetime_picker :deadline, :no_label => true %> +
+
+ +
+ + +
+ + +
+ +
+ <% @tags.each do |tag| %> + + <% end %> +
+
+ +
+ + +
+ + +
+ +
+ <%= f.select :link_open, AdImage::LINK_OPEN_TYPES.map{|a| [t("ad_banner.#{a}"), a]} %> +
+
+ +
+ + +
+ + +
+ +
+ <%= f.number_field :weight, placeholder: t(:frequency), in: 1..99, maxlength: 2, onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;" %> + <%= t('ad_banner.enter_number') %> +
+
+ +
+ + + + + +
+ + +
+ +
+
+
+ <% if @ad_image.file.file %> + <%= image_tag @ad_image.file %> + <% else %> + + <% end %> +
+
+ + <%= t(:select_image) %> + <%= t(:change) %> + <%= f.file_field :file %> + + <%= t(:cancel) %> +
+ +
+
+
+
+ +
+ +
+ + + + + + +
+ + <% I18n.available_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+ <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@ad_image.title_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+
+ <%= f.fields_for :context_translations do |f| %> + <%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@ad_image.context_translations[locale] rescue nil) %> + <% end %> +
+
+
+ +
+ + <% end %> + +
+ +
+ + +
+ <%= f.submit t('submit'), class: 'btn btn-primary' %> +
diff --git a/app/views/admin/ad_images/edit.html.erb b/app/views/admin/ad_images/edit.html.erb new file mode 100644 index 0000000..113b93e --- /dev/null +++ b/app/views/admin/ad_images/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @ad_image, url: admin_ad_image_path(@ad_image), html: {class: "form-horizontal main-forms"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/ad_images/index.html.erb b/app/views/admin/ad_images/index.html.erb index 17f04e3..856ab43 100644 --- a/app/views/admin/ad_images/index.html.erb +++ b/app/views/admin/ad_images/index.html.erb @@ -1,5 +1,33 @@ -<% @ad_images.each do |a|%> - <%= a.title %> - <%= a.banner.title%> - <%=image_tag(a.file.url(:thumb))%> -<% end %> \ No newline at end of file + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + <% @ad_images.each do |image| %> + + + + + + + + + <% end %> + +
<%= image.banner.title %> + <%= image.title %> + + <%= format_value image.postdate %><%= format_value image.deadline %><%= image.out_link rescue " " %>
diff --git a/app/views/admin/ad_images/new.html.erb b/app/views/admin/ad_images/new.html.erb index fb78475..288ae4f 100644 --- a/app/views/admin/ad_images/new.html.erb +++ b/app/views/admin/ad_images/new.html.erb @@ -1,24 +1,5 @@ -<%= form_for(@ad_image, url: {action: "create"}) do |f| %> - <% I18n.available_locales.each do |locale| %> - Title <%= locale.to_s %>: - <%= f.fields_for :title_translations do |n| %> - <%= n.text_field locale %> - <% end %> - - Context <%= locale.to_s %>: - <%= f.fields_for :context_translations do |n| %> - <%= n.text_area locale %> - <% end %> - <% end %> - -

- - <%= image_tag(@ad_image.file_url) if @ad_image.file? %> - <%= f.file_field :file %> - <%= f.hidden_field :file_cache %> -

- - <%= f.select :banner_id, @ad_banners.collect{|t| [ t.title, t.id ]} %> - - <%= f.submit "Create Banner Image" %> +<%= form_for @ad_image, url: admin_ad_images_path, html: {class: "form-horizontal main-forms"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
<% end %> \ No newline at end of file diff --git a/lib/ad_banner/engine.rb b/lib/ad_banner/engine.rb index abb4116..505e96c 100644 --- a/lib/ad_banner/engine.rb +++ b/lib/ad_banner/engine.rb @@ -13,23 +13,23 @@ module AdBanner side_bar do head_label_i18n 'ad_banner.ad_banner', icon_class: "icons-landscape" available_for [:admin,:manager,:sub_manager] - active_for_controllers ({:private=>['ad_banner']}) + active_for_controllers (['admin/ad_banners','admin/ad_images']) head_link_path "admin_ad_banners_path" context_link 'ad_banner.all', :link_path=>"admin_ad_images_path" , :priority=>1, - :active_for_action=>{'admin/ad_banners'=>:index} + :active_for_action=>{'admin/ad_images'=>"index"} context_link 'ad_banner.add', :link_path=>"new_admin_ad_image_path" , :priority=>1, - :active_for_action=>{'admin/ad_banners'=>:index} + :active_for_action=>{'admin/ad_images'=>"new"} context_link 'ad_banner.banner', :link_path=>"admin_ad_banners_path" , :priority=>3, - :active_for_action=>{'admin/ad_banners'=>:index} + :active_for_action=>{'admin/ad_banners'=>"index"} end end end