parent
2be914ac58
commit
8ea0541801
10 changed files with 178 additions and 15 deletions
File diff suppressed because one or more lines are too long
@ -0,0 +1,109 @@ |
||||
var EXPO = EXPO || {}; //isolated namespace
|
||||
if (EXPO.newsFilter) { |
||||
console.warn('WARNING: EXPO.newsFilter is already defined!'); |
||||
} else { |
||||
EXPO.newsFilter = (function () { |
||||
/** |
||||
* private (visible inside this module only) variables |
||||
*/ |
||||
/** |
||||
* @type {Object} - module API interafce realization |
||||
*/ |
||||
var that = {}; |
||||
/** |
||||
* @type {Object} default setting |
||||
*/ |
||||
that.opt = {}; |
||||
/** |
||||
* dependencies.Place where you can switch on dependencies for module |
||||
* @type {EXPO.common|*} - mostly used in project functions and data (block.common.js) |
||||
*/ |
||||
var com = EXPO.common; |
||||
|
||||
/** |
||||
* current module general initialization |
||||
* @param {Object} options - options recieved from web page view |
||||
*/ |
||||
|
||||
|
||||
that.init = function (options) { |
||||
// settings extending
|
||||
$.extend(this.opt, options); |
||||
// begin of initialization
|
||||
var self = this; |
||||
|
||||
$(function () { |
||||
var $page = $(".news-filter-block"), |
||||
$theme = $('.custom-select.theme select', $page), |
||||
$tags = $(".custom-select.tags input", $page), |
||||
$form = $page.children("form"); |
||||
$theme.attr("multiple","multiple"); |
||||
$theme.select2({ |
||||
placeholder: self.opt.theme.placeholder, |
||||
width: '368px', |
||||
maximumSelectionSize: 3 |
||||
|
||||
|
||||
|
||||
}); |
||||
$tags.val('0'); |
||||
$tags.select2({ |
||||
placeholder: self.opt.tags.placeholder, |
||||
width: '368px', |
||||
multiple: true, |
||||
maximumSelectionSize: 5, |
||||
ajax: { |
||||
|
||||
url: self.opt.tags.url, |
||||
dataType: "json", |
||||
quietMillis: 200, |
||||
|
||||
data: function(term, page){ |
||||
var themes = $theme.val(); |
||||
if(!themes){ |
||||
themes = []; |
||||
} |
||||
return {term: term, |
||||
page: page, |
||||
themes: themes}; |
||||
}, |
||||
|
||||
results: function (data) { |
||||
var results = []; |
||||
|
||||
$.each(data, function(index, item){ |
||||
results.push({ |
||||
id: item.id, |
||||
text: item.label |
||||
}); |
||||
}); |
||||
return {results: results}; |
||||
} |
||||
}, |
||||
initSelection : function(element, callback) { |
||||
var data = [], |
||||
dataObjArr; |
||||
element.val(''); |
||||
if($.trim(element.attr('data-predifined')) != '' && $.trim(element.attr('data-predifined')) != '[]'){ |
||||
dataObjArr = JSON.parse(element.attr('data-predifined')); |
||||
callback(dataObjArr); |
||||
}else{ |
||||
$(" .custom-select.tags .select2-input").width(336).addClass('select2-default').val(self.opt.tags.placeholder); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
}); |
||||
$tags.on('change', function (e) { |
||||
$form.submit(); |
||||
}); |
||||
$theme.on('change', function (e) { |
||||
$form.submit(); |
||||
}); |
||||
}); |
||||
|
||||
}; |
||||
return that; |
||||
}()); |
||||
} |
||||
@ -0,0 +1 @@ |
||||
var EXPO=EXPO||{};EXPO.newsFilter?console.warn("WARNING: EXPO.newsFilter is already defined!"):EXPO.newsFilter=function(){var t={};t.opt={};EXPO.common;return t.init=function(t){$.extend(this.opt,t);var e=this;$(function(){var t=$(".news-filter-block"),i=$(".custom-select.theme select",t),a=$(".custom-select.tags input",t),l=t.children("form");i.attr("multiple","multiple"),i.select2({placeholder:e.opt.theme.placeholder,width:"368px",maximumSelectionSize:3}),a.val("0"),a.select2({placeholder:e.opt.tags.placeholder,width:"368px",multiple:!0,maximumSelectionSize:5,ajax:{url:e.opt.tags.url,dataType:"json",quietMillis:200,data:function(t,e){var a=i.val();return a||(a=[]),{term:t,page:e,themes:a}},results:function(t){var e=[];return $.each(t,function(t,i){e.push({id:i.id,text:i.label})}),{results:e}}},initSelection:function(t,i){var a;t.val(""),""!=$.trim(t.attr("data-predifined"))&&"[]"!=$.trim(t.attr("data-predifined"))?(a=JSON.parse(t.attr("data-predifined")),i(a)):$(" .custom-select.tags .select2-input").width(336).addClass("select2-default").val(e.opt.tags.placeholder)}}),a.on("change",function(){l.submit()}),i.on("change",function(){l.submit()})})},t}(); |
||||
File diff suppressed because one or more lines are too long
@ -1 +1 @@ |
||||
var EXPO=EXPO||{};EXPO.profile=EXPO.profile||{},EXPO.profile.calendar?console.warn("WARNING: EXPO.profile.calendar is already defined!"):EXPO.profile.calendar=function(){var t=(EXPO.common,{});return t.opt={},$(function(){}),t.init=function(t){$.extend(this.opt,t);var e=this,s=$("#"+this.opt.scrollBoxId),n=$("#"+this.opt.calenadrId),a=(n.find("td."+this.opt.currentDayClass).index()*this.opt.cellWidth,$("#"+this.opt.scrollLeftId)),o=$("#"+this.opt.scrollRightId),r=$("."+this.opt.noEventsClass),l=$("."+this.opt.calendarToggleClass),i=this.opt.cellWidth*this.opt.cellsToScroll,c=0,d=function(){var t,s,n=0,a=0,o=e.opt.cellWidth,r=$("#"+e.opt.calenadrId),l=r.find("td."+e.opt.currentDayClass).index(),i=e.opt.cellsToScroll,c=r.find("."+e.opt.daysClass+" td").length;return e.stepWidth=i*o,e.calendarWidth=o*c,l>0?(l++,t=c/i,s=c/l,a=t-s,e.currentDay=l,a?(a=Math.floor(a-1),n=i*a*o):n=0):(e.currentDay=0,n=0),n};this.currentOffset=d(),this.$messages=[],$(function(){r.each(function(){$(this).attr("colspan")&&1!=$(this).attr("colspan")?$(this).width()>e.stepWidth&&e.$messages.push($(".message",$(this)).width(e.stepWidth).css({marginLeft:e.currentOffset+"px"})):$(this).find("."+e.opt.eventWrapClass).addClass("small")}),$("."+e.opt.eventsClass).each(function(){c++,3==c&&$(this).addClass("grey"),4==c&&($(this).addClass("grey"),c=0)})}),$(window).load(function(){s.mCustomScrollbar({axis:"y",horizontalScroll:!0,setLeft:"-"+EXPO.profile.calendar.currentOffset+"px",mouseWheel:{enable:!1},scrollButtons:{enable:!1},contentTouchScroll:!1,scrollInertia:1e3,timeout:0,advanced:{autoScrollOnFocus:!1,updateOnContentResize:!1,updateOnBrowserResize:!1},keyboard:{enable:!1}})}),a.on("click",function(){if(e.currentOffset>=e.stepWidth){e.currentOffset-=i,s.mCustomScrollbar("scrollTo","+="+i);for(var t=0;t<e.$messages.length;t++){var n=parseInt(e.$messages[t].inlineStyle("margin-left"));n>0&&e.$messages[t].css({marginLeft:e.currentOffset+"px"})}}}),o.on("click",function(){if(e.currentOffset+e.stepWidth<e.calendarWidth){e.currentOffset+=i,s.mCustomScrollbar("scrollTo","-="+i);for(var t=0;t<e.$messages.length;t++){var n=parseInt(e.$messages[t].inlineStyle("margin-left"));n+e.$messages[t].width()<e.calendarWidth&&e.$messages[t].css({marginLeft:e.currentOffset+"px"})}}}),l.on("click",function(){var t=$(this),e=t.closest(".ep-sect"),s=e.children("div.ep-sect-body");return e.hasClass("eps-opened")?(o.hide(),a.hide(),s.stop().animate({opacity:0},300,function(){e.removeClass("eps-opened")})):(o.show(),a.show(),s.stop().animate({opacity:1},300,function(){e.addClass("eps-opened")})),!1})},t}(); |
||||
var EXPO=EXPO||{};EXPO.profile=EXPO.profile||{},EXPO.profile.calendar?console.warn("WARNING: EXPO.profile.calendar is already defined!"):EXPO.profile.calendar=function(){var e=(EXPO.common,{});return e.opt={},$(function(){$("#btn_delete").on("click",function(e){e.preventDefault();var t=$("input[name=expo]:checkbox:checked").map(function(){return $(this).val()}).get(),s=$("input[name=conf]:checkbox:checked").map(function(){return $(this).val()}).get(),n=$("input[name=seminar]:checkbox:checked").map(function(){return $(this).val()}).get(),a=$("input[name=webinar]:checkbox:checked").map(function(){return $(this).val()}).get(),i={expo:JSON.stringify(t),conf:JSON.stringify(s),seminar:JSON.stringify(n),webinar:JSON.stringify(a)};$.get("/profile/calendar/remove/",i,function(e){e.success&&location.reload()})})}),e.init=function(e){$.extend(this.opt,e);var t=this,s=$("#"+this.opt.scrollBoxId),n=$("#"+this.opt.calenadrId),a=(n.find("td."+this.opt.currentDayClass).index()*this.opt.cellWidth,$("#"+this.opt.scrollLeftId)),i=$("#"+this.opt.scrollRightId),o=$("."+this.opt.noEventsClass),r=$("."+this.opt.calendarToggleClass),c=this.opt.cellWidth*this.opt.cellsToScroll,l=0,d=function(){var e,s,n=0,a=0,i=t.opt.cellWidth,o=$("#"+t.opt.calenadrId),r=o.find("td."+t.opt.currentDayClass).index(),c=t.opt.cellsToScroll,l=o.find("."+t.opt.daysClass+" td").length;return t.stepWidth=c*i,t.calendarWidth=i*l,r>0?(r++,e=l/c,s=l/r,a=e-s,t.currentDay=r,a?(a=Math.floor(a-1),n=c*a*i):n=0):(t.currentDay=0,n=0),n};this.currentOffset=d(),this.$messages=[],$(function(){o.each(function(){$(this).attr("colspan")&&1!=$(this).attr("colspan")?$(this).width()>t.stepWidth&&t.$messages.push($(".message",$(this)).width(t.stepWidth).css({marginLeft:t.currentOffset+"px"})):$(this).find("."+t.opt.eventWrapClass).addClass("small")}),$("."+t.opt.eventsClass).each(function(){l++,3==l&&$(this).addClass("grey"),4==l&&($(this).addClass("grey"),l=0)})}),$(window).load(function(){s.mCustomScrollbar({axis:"y",horizontalScroll:!0,setLeft:"-"+EXPO.profile.calendar.currentOffset+"px",mouseWheel:{enable:!1},scrollButtons:{enable:!1},contentTouchScroll:!1,scrollInertia:1e3,timeout:0,advanced:{autoScrollOnFocus:!1,updateOnContentResize:!1,updateOnBrowserResize:!1},keyboard:{enable:!1}})}),a.on("click",function(){if(t.currentOffset>=t.stepWidth){t.currentOffset-=c,s.mCustomScrollbar("scrollTo","+="+c);for(var e=0;e<t.$messages.length;e++){var n=parseInt(t.$messages[e].inlineStyle("margin-left"));n>0&&t.$messages[e].css({marginLeft:t.currentOffset+"px"})}}}),i.on("click",function(){if(t.currentOffset+t.stepWidth<t.calendarWidth){t.currentOffset+=c,s.mCustomScrollbar("scrollTo","-="+c);for(var e=0;e<t.$messages.length;e++){var n=parseInt(t.$messages[e].inlineStyle("margin-left"));n+t.$messages[e].width()<t.calendarWidth&&t.$messages[e].css({marginLeft:t.currentOffset+"px"})}}}),r.on("click",function(){var e=$(this),t=e.closest(".ep-sect"),s=t.children("div.ep-sect-body");return t.hasClass("eps-opened")?(i.hide(),a.hide(),s.stop().animate({opacity:0},300,function(){t.removeClass("eps-opened")})):(i.show(),a.show(),s.stop().animate({opacity:1},300,function(){t.addClass("eps-opened")})),!1})},e}(); |
||||
Loading…
Reference in new issue