How to use _start method in locust

Best Python code snippet using locust

jquery.touchSlider.js

Source:jquery.touchSlider.js Github

copy

Full Screen

1/**2 * @name jQuery.touchSlider3 * @version 201209_24 * @since 2011065 * @param Object settings 환경변수 오브젝트6 * roll - 순환 (default true)7 * flexible - 유동 레이아웃 (default false)8 * view - 다중 컬럼 (default 1)9 * speed - 애니메이션 속도 (default 75)10 * range - 넘김 판정 범위 (default 0.15)11 * page - 초기 페이지 (default 1)12 * transition - CSS3 transition 사용 (default false)13 * btn_prev - prev 버튼 (jQuery Object, default null)14 * btn_next - next 버튼 (jQuery Object, default null)15 * paging - page 버튼 (jQuery Object, default null)16 * initComplete - 초기화 콜백17 * counter - 슬라이드 콜백, 카운터18 *19 * @example20 $("#target").touchSlider({21 flexible : true22 });23*/24(function ($) {25 26 $.fn.touchSlider = function (settings) {27 28 settings.supportsCssTransitions = (function (style) {29 var prefixes = ['Webkit','Moz','Ms'];30 for(var i=0, l=prefixes.length; i < l; i++ ) {31 if( typeof style[prefixes[i] + 'Transition'] !== 'undefined') {32 return true;33 }34 }35 return false;36 })(document.createElement('div').style);37 38 settings = jQuery.extend({39 roll : true,40 flexible : false,41 btn_prev : null,42 btn_next : null,43 paging : null,44 speed : 75,45 view : 1,46 range : 0.15,47 page : 1,48 autoplay: true,49 transition : false,50 initComplete : null,51 counter : null,52 multi : false53 54 }, settings);55 56 var opts = [];57 opts = $.extend({}, $.fn.touchSlider.defaults, settings);58 59 return this.each(function () {60 61 $.fn.extend(this, touchSlider);62 63 var _this = this;64 65 this.opts = opts;66 this._view = this.opts.view;67 this._speed = this.opts.speed;68 this._tg = $(this);69 this._list = this._tg.children().children();70 this._width = parseInt(this._tg.css("width"));71 this._item_w = parseInt(this._list.css("width"));72 this._len = this._list.length;73 this._range = this.opts.range * this._width;74 this._pos = [];75 this._start = [];76 this._startX = 0;77 this._startY = 0;78 this._left = 0;79 this._top = 0;80 this._drag = false;81 this._scroll = false;82 this._btn_prev;83 this._btn_next;84 85 this.init();86 87 $(this)88 .bind("touchstart", this.touchstart)89 .bind("touchmove", this.touchmove)90 .bind("touchend", this.touchend)91 .bind("dragstart", this.touchstart)92 .bind("drag", this.touchmove)93 .bind("dragend", this.touchend)94 95 $(window).bind("orientationchange resize", function () {96 _this.resize(_this);97 });98 });99 100 };101 102 var touchSlider = {103 104 init : function () {105 var _this = this;106 107 $(this).children().css({108 "width":this._width + "px",109 "overflow":"visible"110 });111 112 if(this.opts.flexible) this._item_w = this._width / this._view;113 if(this.opts.roll) this._len = Math.ceil(this._len / this._view) * this._view;114 115 var page_gap = (this.opts.page > 1 && this.opts.page <= this._len) ? (this.opts.page - 1) * this._item_w : 0;116 117 for(var i=0; i<this._len; ++i) {118 this._pos[i] = this._item_w * i - page_gap;119 this._start[i] = this._pos[i];120 this._list.eq(i).css({121 "float" : "none",122 "display" : "block",123 "position" : "absolute",124 "top" : "0",125 "left" : this._pos[i] + "px",126 "width" : this._item_w + "px"127 });128 if(this.opts.supportsCssTransitions && this.opts.transition) {129 this._list.eq(i).css({130 "-moz-transition" : "0ms",131 "-moz-transform" : "",132 "-ms-transition" : "0ms",133 "-ms-transform" : "",134 "-webkit-transition" : "0ms",135 "-webkit-transform" : "",136 "transition" : "0ms",137 "transform" : ""138 });139 }140 }141 142 if(this.opts.btn_prev && this.opts.btn_next) {143 this.opts.btn_prev.bind("click", function() {144 _this.animate(1, true);145 return false;146 })147 this.opts.btn_next.bind("click", function() {148 _this.animate(-1, true);149 return false;150 });151 }152 153 if(this.opts.paging) {154 $(this._list).each(function (i, el) {155 //var btn_page = _this.opts.paging.eq(0).clone();156 var btn_page = _this.opts.paging.eq(i);157 //_this.opts.paging.before(btn_page);158 159 btn_page.bind("click", function(e) {160 _this.go_page(i, e);161 return false;162 });163 });164 165 //this.opts.paging.remove();166 }167 168 this.counter();169 this.initComplete();170 },171 172 initComplete : function () {173 if(typeof(this.opts.initComplete) == "function") {174 this.opts.initComplete(this);175 }176 },177 178 resize : function (e) {179 if(e.opts.flexible) {180 var tmp_w = e._item_w;181 182 e._width = parseInt(e._tg.css("width"));183 e._item_w = e._width / e._view;184 e._range = e.opts.range * e._width;185 186 for(var i=0; i<e._len; ++i) {187 e._pos[i] = e._pos[i] / tmp_w * e._item_w;188 e._start[i] = e._start[i] / tmp_w * e._item_w;189 e._list.eq(i).css({190 "left" : e._pos[i] + "px",191 "width" : e._item_w + "px"192 });193 if(this.opts.supportsCssTransitions && this.opts.transition) {194 e._list.eq(i).css({195 "-moz-transition" : "0ms",196 "-moz-transform" : "",197 "-ms-transition" : "0ms",198 "-ms-transform" : "",199 "-webkit-transition" : "0ms",200 "-webkit-transform" : "",201 "transition" : "0ms",202 "transform" : ""203 });204 }205 }206 }207 208 this.counter();209 },210 211 touchstart : function (e) { 212 if((e.type == "touchstart" && e.originalEvent.touches.length <= 1) || e.type == "dragstart") {213 this._startX = e.pageX || e.originalEvent.touches[0].pageX;214 this._startY = e.pageY || e.originalEvent.touches[0].pageY;215 this._scroll = false;216 217 this._start = [];218 for(var i=0; i<this._len; ++i) {219 this._start[i] = this._pos[i];220 }221 }222 },223 224 touchmove : function (e) { 225 if((e.type == "touchmove" && e.originalEvent.touches.length <= 1) || e.type == "drag") {226 this._left = (e.pageX || e.originalEvent.touches[0].pageX) - this._startX;227 this._top = (e.pageY || e.originalEvent.touches[0].pageY) - this._startY;228 var w = this._left < 0 ? this._left * -1 : this._left;229 var h = this._top < 0 ? this._top * -1 : this._top;230 231 if (w < h || this._scroll) {232 this._left = 0;233 this._drag = false;234 this._scroll = true;235 } else {236 e.preventDefault();237 this._drag = true;238 this._scroll = false;239 this.position(e);240 }241 242 for(var i=0; i<this._len; ++i) {243 var tmp = this._start[i] + this._left;244 245 if(this.opts.supportsCssTransitions && this.opts.transition) {246 var trans = "translate3d(" + tmp + "px,0,0)";247 this._list.eq(i).css({248 "left" : "",249 "-moz-transition" : "0ms",250 "-moz-transform" : trans,251 "-ms-transition" : "0ms",252 "-ms-transform" : trans,253 "-webkit-transition" : "0ms",254 "-webkit-transform" : trans,255 "transition" : "0ms",256 "transform" : trans257 });258 } else {259 this._list.eq(i).css("left", tmp + "px");260 }261 262 this._pos[i] = tmp;263 }264 }265 },266 267 touchend : function (e) {268 if((e.type == "touchend" && e.originalEvent.touches.length <= 1) || e.type == "dragend") {269 if(this._scroll) {270 this._drag = false;271 this._scroll = false;272 return false;273 }274 275 this.animate(this.direction());276 this._drag = false;277 this._scroll = false;278 }279 },280 281 position : function (d) { 282 var gap = this._view * this._item_w;283 284 if(d == -1 || d == 1) {285 this._startX = 0;286 this._start = [];287 for(var i=0; i<this._len; ++i) {288 this._start[i] = this._pos[i];289 }290 this._left = d * gap;291 } else {292 if(this._left > gap) this._left = gap;293 if(this._left < - gap) this._left = - gap;294 }295 296 if(this.opts.roll) {297 var tmp_pos = [];298 for(var i=0; i<this._len; ++i) {299 tmp_pos[i] = this._pos[i];300 }301 tmp_pos.sort(function(a,b){return a-b;});302 303 var max_chk = tmp_pos[this._len-this._view];304 var p_min = $.inArray(tmp_pos[0], this._pos);305 var p_max = $.inArray(max_chk, this._pos);306 307 if(this._view <= 1) max_chk = this._len - 1;308 if(this.opts.multi) {309 if((d == 1 && tmp_pos[0] >= 0) || (this._drag && tmp_pos[0] >= 100)) {310 for(var i=0; i<this._view; ++i, ++p_min, ++p_max) {311 this._start[p_max] = this._start[p_min] - gap;312 this._list.eq(p_max).css("left", this._start[p_max] + "px");313 }314 } else if((d == -1 && tmp_pos[0] <= 0) || (this._drag && tmp_pos[0] <= -100)) {315 for(var i=0; i<this._view; ++i, ++p_min, ++p_max) {316 this._start[p_min] = this._start[p_max] + gap;317 this._list.eq(p_min).css("left", this._start[p_min] + "px");318 }319 }320 } else {321 if((d == 1 && tmp_pos[0] >= 0) || (this._drag && tmp_pos[0] > 0)) {322 for(var i=0; i<this._view; ++i, ++p_min, ++p_max) {323 this._start[p_max] = this._start[p_min] - gap;324 this._list.eq(p_max).css("left", this._start[p_max] + "px");325 }326 } else if((d == -1 && tmp_pos[max_chk] <= 0) || (this._drag && tmp_pos[max_chk] <= 0)) {327 for(var i=0; i<this._view; ++i, ++p_min, ++p_max) {328 this._start[p_min] = this._start[p_max] + gap;329 this._list.eq(p_min).css("left", this._start[p_min] + "px");330 }331 }332 }333 } else {334 if(this.limit_chk()) this._left = this._left / 2;335 }336 },337 338 animate : function (d, btn_click) {339 if(this._drag || !this._scroll || btn_click) {340 var _this = this;341 var speed = this._speed;342 343 if(btn_click) this.position(d);344 345 var gap = d * (this._item_w * this._view);346 if(this._left == 0 || (!this.opts.roll && this.limit_chk()) ) gap = 0;347 348 this._list.each(function (i, el) {349 _this._pos[i] = _this._start[i] + gap;350 351 if(_this.opts.supportsCssTransitions && _this.opts.transition) {352 var transition = speed + "ms";353 var transform = "translate3d(" + _this._pos[i] + "px,0,0)";354 355 if(btn_click) transition = "0ms";356 357 $(this).css({358 "left" : "",359 "-moz-transition" : transition,360 "-moz-transform" : transform,361 "-ms-transition" : transition,362 "-ms-transform" : transform,363 "-webkit-transition" : transition,364 "-webkit-transform" : transform,365 "transition" : transition,366 "transform" : transform367 });368 } else {369 $(this).stop();370 $(this).animate({"left": _this._pos[i] + "px"}, speed);371 }372 }); 373 374 this.counter();375 }376 },377 378 direction : function () { 379 var r = 0;380 381 if(this._left < -(this._range)) r = -1;382 else if(this._left > this._range) r = 1;383 384 if(!this._drag || this._scroll) r = 0;385 386 return r;387 },388 389 limit_chk : function () {390 var last_p = parseInt((this._len - 1) / this._view) * this._view;391 return ( (this._start[0] == 0 && this._left > 0) || (this._start[last_p] == 0 && this._left < 0) );392 },393 394 go_page : function (i, e) {395 var crt = ($.inArray(0, this._pos) / this._view) + 1;396 var cal = crt - (i + 1);397 398 while(cal != 0) {399 if(cal < 0) {400 this.animate(-1, true);401 cal++;402 } else if(cal > 0) {403 this.animate(1, true);404 cal--;405 }406 }407 },408 409 counter : function () {410 if(typeof(this.opts.counter) == "function") {411 var param = {412 total : Math.ceil(this._len / this._view),413 current : ($.inArray(0, this._pos) / this._view) + 1414 };415 this.opts.counter(param);416 }417 }418 419 };420})(jQuery);421$(document).ready(function(){422 423 424 $dragBln = false;425 426 $(".main_image").touchSlider({427 flexible : true,428 speed : 200,429 btn_prev : $("#btn_prev"),430 btn_next : $("#btn_next"),431 paging : $(".flicking_con a"),432 counter : function (e){433 $(".flicking_con a").removeClass("on").eq(e.current-1).addClass("on");434 }435 });436 437 $(".main_image").bind("mousedown", function() {438 $dragBln = false;439 });440 441 $(".main_image").bind("dragstart", function() {442 $dragBln = true;443 });444 445 $(".main_image a").click(function(){446 if($dragBln) {447 return false;448 }449 });450 451 timer = setInterval(function(){452 $("#btn_next").click();453 }, 3000);454 455 $(".main_visual").hover(function(){456 clearInterval(timer);457 },function(){458 timer = setInterval(function(){459 $("#btn_next").click();460 },3000);461 });462 463 $(".main_image").bind("touchstart",function(){464 clearInterval(timer);465 }).bind("touchend", function(){466 timer = setInterval(function(){467 $("#btn_next").click();468 }, 3000);469 });470 ...

Full Screen

Full Screen

WideInterval.js

Source:WideInterval.js Github

copy

Full Screen

1/*2 * This file is part of YoHours.3 * 4 * YoHours is free software: you can redistribute it and/or modify5 * it under the terms of the GNU Affero General Public License as published by6 * the Free Software Foundation, either version 3 of the License, or7 * any later version.8 * 9 * YoHours is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU Affero General Public License for more details.13 * 14 * You should have received a copy of the GNU Affero General Public License15 * along with YoHours. If not, see <http://www.gnu.org/licenses/>.16 */17//IMPORTS18let Constants = require("./Constants");19/**20 * A wide interval is an interval of one or more days, weeks, months, holidays.21 * Use WideInterval.days/weeks/months/holidays methods to construct one object.22 */23class WideInterval {24//CONSTRUCTOR25 constructor() {26 /** The start of the interval **/27 this._start = null;28 29 /** The end of the interval **/30 this._end = null;31 /** The kind of interval **/32 this._type = null;33 }34//CONSTRUCTORS35 /**36 * @return a day-based interval37 */38 day(startDay, startMonth, endDay, endMonth) {39 if(startDay == null || startMonth == null) {40 throw Error("Start day and month can't be null");41 }42 this._start = { day: startDay, month: startMonth };43 this._end = (endDay != null && endMonth != null && (endDay != startDay || endMonth != startMonth)) ? { day: endDay, month: endMonth } : null;44 this._type = "day";45 return this;46 }47 48 /**49 * @return a week-based interval50 */51 week(startWeek, endWeek) {52 if(startWeek == null) {53 throw Error("Start week can't be null");54 }55 this._start = { week: startWeek };56 this._end = (endWeek != null && endWeek != startWeek) ? { week: endWeek } : null;57 this._type = "week";58 return this;59 }60 61 /**62 * @return a month-based interval63 */64 month(startMonth, endMonth) {65 if(startMonth == null) {66 throw Error("Start month can't be null");67 }68 this._start = { month: startMonth };69 this._end = (endMonth != null && endMonth != startMonth) ? { month: endMonth } : null;70 this._type = "month";71 return this;72 }73 74 /**75 * @return a holiday-based interval76 */77 holiday(holiday) {78 if(holiday == null || (holiday != "PH" && holiday != "SH" && holiday != "easter")) {79 throw Error("Invalid holiday, must be PH, SH or easter");80 }81 this._start = { holiday: holiday };82 this._end = null;83 this._type = "holiday";84 return this;85 }86 87 /**88 * @return a holiday-based interval89 */90 always() {91 this._start = null;92 this._end = null;93 this._type = "always";94 return this;95 }96//ACCESSORS97 /**98 * @return The kind of wide interval (always, day, month, week, holiday)99 */100 getType() {101 return this._type;102 }103 104 /**105 * @return The start moment106 */107 getStart() {108 return this._start;109 }110 111 /**112 * @return The end moment113 */114 getEnd() {115 return this._end;116 }117 118 /**119 * @return True if the given object concerns the same interval as this one120 */121 equals(o) {122 if(!o instanceof WideInterval) { return false; }123 if(this === o) { return true; }124 if(o._type == "always") { return this._type == "always"; }125 let result = false;126 127 switch(this._type) {128 case "always":129 result = o._start == null;130 break;131 case "day":132 result =133 (134 o._type == "day"135 && o._start.month == this._start.month136 && o._start.day == this._start.day137 && (138 (o._end == null && this._end == null)139 || (o._end != null && this._end != null && this._end.month == o._end.month && this._end.day == o._end.day)140 ))141 ||142 (143 o._type == "month"144 && o._start.month == this._start.month145 && (this.isFullMonth() && o.isFullMonth())146 || (o._end != null && this._end != null && this._end.month == o._end.month && this.endsMonth() && o.endsMonth())147 );148 break;149 case "week":150 result =151 o._start.week == this._start.week152 && (o._end == this._end || (this._end != null && o._end != null && o._end.week == this._end.week));153 break;154 case "month":155 result = 156 (157 o._type == "day"158 && this._start.month == o._start.month159 && o.startsMonth()160 && (161 (this._end == null && o._end != null && this._start.month == o._end.month && o.endsMonth())162 ||163 (this._end != null && o._end != null && this._end.month == o._end.month && o.endsMonth())164 )165 )166 ||167 (168 o._type == "month"169 && o._start.month == this._start.month170 && (171 (this._end == null && o._end == null)172 ||173 (this._end != null && o._end != null && this._end.month == o._end.month)174 )175 );176 break;177 case "holiday":178 result = o._start.holiday == this._start.holiday;179 break;180 default:181 }182 183 return result;184 }185 186 /**187 * @return The human readable time188 */189 getTimeForHumans() {190 let result;191 192 switch(this._type) {193 case "day":194 if(this._end != null) {195 result = "every week from "+Constants.IRL_MONTHS[this._start.month-1]+" "+this._start.day+" to ";196 if(this._start.month != this._end.month) { result += Constants.IRL_MONTHS[this._end.month-1]+" "; }197 result += this._end.day;198 }199 else {200 result = "day "+Constants.IRL_MONTHS[this._start.month-1]+" "+this._start.day;201 }202 break;203 case "week":204 if(this._end != null) {205 result = "every week from week "+this._start.week+" to "+this._end.week;206 }207 else {208 result = "week "+this._start.week;209 }210 break;211 case "month":212 if(this._end != null) {213 result = "every week from "+Constants.IRL_MONTHS[this._start.month-1]+" to "+Constants.IRL_MONTHS[this._end.month-1];214 }215 else {216 result = "every week in "+Constants.IRL_MONTHS[this._start.month-1];217 }218 break;219 case "holiday":220 if(this._start.holiday == "SH") {221 result = "every week during school holidays";222 }223 else if(this._start.holiday == "PH") {224 result = "every public holidays";225 }226 else if(this._start.holiday == "easter") {227 result = "each easter day";228 }229 else {230 throw new Error("Invalid holiday type: "+this._start.holiday);231 }232 break;233 case "always":234 result = "every week of year";235 break;236 default:237 result = "invalid time";238 }239 240 return result;241 }242 243 /**244 * @return The time selector for OSM opening_hours245 */246 getTimeSelector() {247 let result;248 249 switch(this._type) {250 case "day":251 result = Constants.OSM_MONTHS[this._start.month-1]+" "+((this._start.day < 10) ? "0" : "")+this._start.day;252 if(this._end != null) {253 //Same month as start ?254 if(this._start.month == this._end.month) {255 result += "-"+((this._end.day < 10) ? "0" : "")+this._end.day;256 }257 else {258 result += "-"+Constants.OSM_MONTHS[this._end.month-1]+" "+((this._end.day < 10) ? "0" : "")+this._end.day;259 }260 }261 break;262 case "week":263 result = "week "+((this._start.week < 10) ? "0" : "")+this._start.week;264 if(this._end != null) {265 result += "-"+((this._end.week < 10) ? "0" : "")+this._end.week;266 }267 break;268 case "month":269 result = Constants.OSM_MONTHS[this._start.month-1];270 if(this._end != null) {271 result += "-"+Constants.OSM_MONTHS[this._end.month-1];272 }273 break;274 case "holiday":275 result = this._start.holiday;276 break;277 case "always":278 default:279 result = "";280 }281 282 return result;283 }284 285 /**286 * Does this interval corresponds to a full month ?287 */288 isFullMonth() {289 if(this._type == "month" && this._end == null) {290 return true;291 }292 else if(this._type == "day") {293 return (this._start.day == 1 && this._end != null && this._end.month == this._start.month && this._end.day != undefined && this._end.day == Constants.MONTH_END_DAY[this._end.month-1]);294 }295 else {296 return false;297 }298 }299 300 /**301 * Does this interval starts the first day of a month302 */303 startsMonth() {304 return this._type == "month" || this._type == "always" || (this._type == "day" && this._start.day == 1);305 }306 307 /**308 * Does this interval ends the last day of a month309 */310 endsMonth() {311 return this._type == "month" || this._type == "always" || (this._type == "day" && this._end != null && this._end.day == Constants.MONTH_END_DAY[this._end.month-1]);312 }313 314 /**315 * Does this interval strictly contains the given one (ie the second is a refinement of the first, and not strictly equal)316 * @param o The other wide interval317 * @return True if this date contains the given one (and is not strictly equal to)318 */319 contains(o) {320 let result = false;321 322 /*323 * Check if it is contained in this one324 */325 if(this.equals(o)) {326 result = false;327 }328 else if(this._type == "always") {329 result = true;330 }331 else if(this._type == "day") {332 if(o._type == "day") {333 //Starting after334 if(o._start.month > this._start.month || (o._start.month == this._start.month && o._start.day >= this._start.day)) {335 //Ending before336 if(o._end != null) {337 if(this._end != null && (o._end.month < this._end.month || (o._end.month == this._end.month && o._end.day <= this._end.day))) {338 result = true;339 }340 }341 else {342 if(this._end != null && (o._start.month < this._end.month || (o._start.month == this._end.month && o._start.day <= this._end.day))) {343 result = true;344 }345 }346 }347 }348 else if(o._type == "month"){349 //Starting after350 if(o._start.month > this._start.month || (o._start.month == this._start.month && this._start.day == 1)) {351 //Ending before352 if(o._end != null && this._end != null && (o._end.month < this._end.month || (o._end.month == this._end.month && this._end.day == Constants.MONTH_END_DAY[end.month-1]))) {353 result = true;354 }355 else if(o._end == null && (this._end != null && o._start.month < this._end.month)) {356 result = true;357 }358 }359 }360 }361 else if(this._type == "week") {362 if(o._type == "week") {363 if(o._start.week >= this._start.week) {364 if(o._end != null && this._end != null && o._end.week <= this._end.week) {365 result = true;366 }367 else if(o._end == null && ((this._end != null && o._start.week <= this._end.week) || o._start.week == this._start.week)) {368 result = true;369 }370 }371 }372 }373 else if(this._type == "month") {374 if(o._type == "month") {375 if(o._start.month >= this._start.month) {376 if(o._end != null && this._end != null && o._end.month <= this._end.month) {377 result = true;378 }379 else if(o._end == null && ((this._end != null && o._start.month <= this._end.month) || o._start.month == this._start.month)) {380 result = true;381 }382 }383 }384 else if(o._type == "day") {385 if(o._end != null) {386 if(this._end == null) {387 if(388 o._start.month == this._start.month389 && o._end.month == this._start.month390 && ((o._start.day >= 1 && o._end.day < Constants.MONTH_END_DAY[o._start.month-1])391 || (o._start.day > 1 && o._end.day <= Constants.MONTH_END_DAY[o._start.month-1]))392 ) {393 result = true;394 }395 }396 else {397 if(o._start.month >= this._start.month && o._end.month <= this._end.month) {398 if(399 (o._start.month > this._start.month && o._end.month < this._end.month)400 || (o._start.month == this._start.month && o._end.month < this._end.month && o._start.day > 1)401 || (o._start.month > this._start.month && o._end.month == this._end.month && o._end.day < Constants.MONTH_END_DAY[o._end.month-1])402 || (o._start.day >= 1 && o._end.day < Constants.MONTH_END_DAY[o._end.month-1])403 || (o._start.day > 1 && o._end.day <= Constants.MONTH_END_DAY[o._end.month-1])404 ) {405 result = true;406 }407 }408 }409 }410 else {411 if(this._end == null) {412 if(this._start.month == o._start.month) {413 result = true;414 }415 }416 else {417 if(o._start.month >= this._start.month && o._start.month <= this._end.month) {418 result = true;419 }420 }421 }422 }423 }424 425 return result;426 }427}...

Full Screen

Full Screen

beta-u-animation-to.js

Source:beta-u-animation-to.js Github

copy

Full Screen

1 // style2 // stroke, fill, 3 // attributes4 // x1, x2, y1, y2, r, cx, cy, d, x, y5 // stroke, stroke-width, fill, stroke-dash-array6 7 // CURRENT THINGS TO CONSIDER8 9 // if animation is running, should new function call take over or work "on top"/"side-by-side"10 // css transitions take over11 u.a.parseSVGPolygon = function(value) {12// u.bug("parseSVGPolygon:" + value)13 // values required for each type14 var pairs = value.trim().split(" ");15 var sets = [];16 var part;17 for(x in pairs) {18 parts = pairs[x].trim().split(",");19 for(part in parts) {20 parts[part] = Number(parts[part]);21 }22 sets[x] = parts;23// if(parts && pairs[parts[0].toLowerCase()] == parts.length-1) {24// // u.bug("valid set:" + parts);25// }26// else {27// // u.bug("invalid set - could be 'dual' set with only one identifier")28// }29 }30// u.bug("sets:" + sets.join("#"));31 // u.bug("value:" + value);32 return sets;33 34 }35 u.a.parseSVGPath = function(value) {36 // values required for each type37 var pairs = {"m":2, "l":2, "a":7, "c":6, "s":4, "q":4, "z":0};38 var x, sets;39 // add structure to string for parsability40 value = value.replace(/-/g, " -");41 value = value.replace(/,/g, " ");42 value = value.replace(/(m|l|a|c|s|q|M|L|A|C|S|Q)/g, " $1 ");43 value = value.replace(/ /g, " ");44 // check values45 sets = value.match(/(m|l|a|c|s|q|M|L|A|C|S|Q)([0-9 \-\.]+)/g);46 for(x in sets) {47 parts = sets[x].trim().split(" ");48 sets[x] = parts;49 if(parts && pairs[parts[0].toLowerCase()] == parts.length-1) {50// u.bug("valid set:" + parts);51 }52 else {53// u.bug("invalid set - could be 'dual' set with only one identifier")54 }55 }56 // u.bug("values:" + sets);57 // u.bug("value:" + value);58 return sets;59 60 }61 u.a.getInitialValue = function(node, attribute) {62 var value = (node.getAttribute(attribute) ? node.getAttribute(attribute) : u.gcs(node, attribute)).replace(node._unit[attribute], "")63 if(attribute.match(/^(d|points)$/)) {64// u.bug("getInitialValue:" +value)65 return value;66// value.split("m|l|a|c|s|M|L|A|C|S");67 }68 else {69 return Number(value.replace(/auto/, 0));70 }71 }72 u.a.to = function(node, transition, attributes) {73// u.bug("to:" + u.nodeId(node) + ", " + transition + ", " + attributes);74 // get duration75// var transition_parts = transition.match(/([a-zA-Z]+) ([0-9.]+[ms]+) ([a-zA-Z\-]+) ([0-9.]+[ms]+)/g);76 var transition_parts = transition.split(" ");77// u.bug(transition_parts)78 if(transition_parts.length >= 3) {79 // u.bug(duration[0]);80 node._target = transition_parts[0];81 node.duration = transition_parts[1].match("ms") ? parseFloat(transition_parts[1]) : (parseFloat(transition_parts[1]) * 1000);82 node._ease = transition_parts[2];83 if(transition_parts.length == 4) {84 node.delay = transition_parts[3].match("ms") ? parseFloat(transition_parts[3]) : (parseFloat(transition_parts[3]) * 1000);85 }86 }87 var value, d;88// u.bug("node._ease:" + node._ease);89 node._start = {};90 node._end = {};91 node._unit = {};92 for(attribute in attributes) {93 // path definitions are 94 if(attribute.match(/^(d)$/)) {95 node._start[attribute] = this.parseSVGPath(this.getInitialValue(node, attribute));96 node._end[attribute] = this.parseSVGPath(attributes[attribute]);97// u.bug("start:" + node._start[attribute].join("#"))98// u.bug("end:" + node._end[attribute])99 // d_parts = this.getInitialValue(node, attribute);100 //101 // u.bug("d_parts:" + d_parts)102 //103 //104 // node._start[attribute] = d_parts.split("m|l|a|c|s|M|L|A|C|S");105 //106 // u.bug("node._start:" + node._start[attribute])107 }108 // polygons109 else if(attribute.match(/^(points)$/)) {110// u.bug("to points:" + u.nodeId(node) + ", " + attributes[attribute])111 node._start[attribute] = this.parseSVGPolygon(this.getInitialValue(node, attribute));112 node._end[attribute] = this.parseSVGPolygon(attributes[attribute]);113// u.bug("start:" + node._start[attribute].join("#"))114 }115 // plain number svg shapes116 else {117 node._unit[attribute] = attributes[attribute].toString().match(/\%|px/);118 node._start[attribute] = this.getInitialValue(node, attribute);119 //(node.getAttribute(attribute) ? node.getAttribute(attribute) : u.gcs(node, attribute)).replace(node._unit[attribute], "");120 node._end[attribute] = attributes[attribute].toString().replace(node._unit[attribute], "");121 }122// u.bug("attributes["+attribute+"] = "+attributes[attribute] + "::"+ node._start[attribute] + " -> " + node._end[attribute]);123 }124// u.bug("duration:" + node.duration);125// u.bug(u.easings);126// u.bug(node._ease + ", " + u.easings[node._ease]);127 node.easing = u.easings[node._ease];128// u.bug(node.easing);129 node.transitionTo = function(progress) {130 var easing = node.easing(progress);131// u.bug("easing:" + easing + ", " + progress)132 for(attribute in attributes) {133 // transform value134 if(attribute.match(/^(translate|rotate|scale)$/)) {135 if(attribute == "translate") {136 u.a.translate(this, Math.round((this._end_x - this._start_x) * easing), Math.round((this._end_y - this._start_y) * easing))137 }138 else if(attribute == "rotate") {139 }140 }141 // plain svg value142 else if(attribute.match(/^(x1|y1|x2|y2|r|cx|cy|stroke-width)$/)) {143 var new_value = (this._start[attribute] + ((this._end[attribute] - this._start[attribute]) * easing)) + this._unit[attribute]144// u.bug("update:" + attribute + ":" + new_value);145 this.setAttribute(attribute, new_value);146 }147 // path d attribute148 else if(attribute.match(/^(d)$/)) {149// u.bug("path")150// var d_parts = this._start[attribute].split("m|l|a|c|s|M|L|A|C|S");151// u.bug("d_parts:" + d_parts)152 var new_value = "";153 for(x in this._start[attribute]) {154 for(y in this._start[attribute][x]) {155// u.bug("pf:" + this._start[attribute][x][y] + " :: " + parseFloat(this._start[attribute][x][y]) + ", " + typeof(this._start[attribute][x][y]))156 if(parseFloat(this._start[attribute][x][y]) == this._start[attribute][x][y]) {157 new_value += (Number(this._start[attribute][x][y]) + ((Number(this._end[attribute][x][y]) - Number(this._start[attribute][x][y])) * easing)) + " ";158 }159 else {160 new_value += this._end[attribute][x][y] + " ";161 }162 }163 }164 // var new_value = (this._start[attribute] + ((this._end[attribute] - this._start[attribute]) * easing)) + this._unit[attribute]165//166// u.bug("set new:" + new_value);167 this.setAttribute(attribute, new_value);168 }169 // polygon point attribute170 else if(attribute.match(/^(points)$/)) {171// u.bug("path")172// var d_parts = this._start[attribute].split("m|l|a|c|s|M|L|A|C|S");173// u.bug("d_parts:" + d_parts)174 var new_value = "";175 for(x in this._start[attribute]) {176 new_value += (this._start[attribute][x][0] + ((this._end[attribute][x][0] - this._start[attribute][x][0]) * easing)) + ",";177 new_value += (this._start[attribute][x][1] + ((this._end[attribute][x][1] - this._start[attribute][x][1]) * easing)) + " ";178 }179 // var new_value = (this._start[attribute] + ((this._end[attribute] - this._start[attribute]) * easing)) + this._unit[attribute]180//181// u.bug("set new:" + new_value);182 this.setAttribute(attribute, new_value);183 }184 // regular attribute185 else {186 //u.bug("update:" + this._end[attribute] + "-" + this._start[attribute] + " * " + easing + " " + this._unit[attribute])187 var new_value = (this._start[attribute] + ((this._end[attribute] - this._start[attribute]) * easing)) + this._unit[attribute]188// u.bug("update:" + attribute + ":" + new_value);189 u.as(node, attribute, new_value, false);190 }191 192 }193 }194// u.bug(u.nodeId(this) + ":easing:" + easing + " ("+(this._end_x - this._start_x) * easing+","+(this._end_y - this._start_y) * easing+")")195 196// u.bug(node.duration);197 u.a.requestAnimationFrame(node, "transitionTo", node.duration);198 }199// this.animationFrame = function(node, callback) {200//201// if(!window._animationframe) {202// window._animationframe = window[this.vendor("requestAnimationFrame")]203//204// }205//206// }207//208//209// window.cancelRequestAnimFrame = ( function() {210// return window.cancelAnimationFrame ||211// window.webkitCancelRequestAnimationFrame ||212// window.mozCancelRequestAnimationFrame ||213// window.oCancelRequestAnimationFrame ||214// window.msCancelRequestAnimationFrame ||215// clearTimeout216// } )();217//218// window.requestAnimFrame = (function() {219// return window.requestAnimationFrame ||220// window.webkitRequestAnimationFrame ||221// window.mozRequestAnimationFrame ||222// window.oRequestAnimationFrame ||223// window.msRequestAnimationFrame ||224// function(callback, element){225// return window.setTimeout(callback, 1000 / 60);226// };227// })();228//229// (function() {230// var lastTime = 0;231// var vendors = ['ms', 'moz', 'webkit', 'o'];232// for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {233// window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];234// window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']235// || window[vendors[x]+'CancelRequestAnimationFrame'];236// }237//238// if (!window.requestAnimationFrame)239// window.requestAnimationFrame = function(callback, element) {240// var currTime = new Date().getTime();241// var timeToCall = Math.max(0, 16 - (currTime - lastTime));242// var id = window.setTimeout(function() { callback(currTime + timeToCall); },243// timeToCall);244// lastTime = currTime + timeToCall;245// return id;246// };247//248// if (!window.cancelAnimationFrame)249// window.cancelAnimationFrame = function(id) {250// clearTimeout(id);251// };...

Full Screen

Full Screen

array-slice.js

Source:array-slice.js Github

copy

Full Screen

1/**2 * An array proxy that exposes only selected slice of real EmberArray.3 * 4 * See tests for usage examples.5 *6 * @module utils/array-slice7 * @author Jakub Liput8 * @copyright (C) 2018 ACK CYFRONET AGH9 * @license This software is released under the MIT license cited in 'LICENSE.txt'.10 */11import Ember from 'ember';12const {13 ArrayProxy,14 computed,15 observer,16} = Ember;17export default ArrayProxy.extend({18 startIndex: 0,19 endIndex: 0,20 indexMargin: 0,21 22 _startCache: undefined,23 _endCache: undefined,24 25 sourceArray: computed.alias('content'),26 27 /**28 * @type {Ember.ComputedProperty<number>}29 */30 maxLength: computed('startIndex', 'endIndex', function getMaxLength() {31 return this.get('endIndex') - this.get('startIndex');32 }),33 34 _start: computed('startIndex', 'indexMargin', function () {35 const {36 startIndex,37 indexMargin,38 } = this.getProperties(39 'startIndex',40 'indexMargin'41 );42 const _start = Math.max(0, startIndex - indexMargin);43 44 this.set('_startCache', _start);45 return _start;46 }),47 48 _end: computed('endIndex', 'indexMargin', 'sourceArray.length', function () {49 const {50 endIndex,51 indexMargin,52 } = this.getProperties(53 'endIndex',54 'indexMargin'55 );56 57 const sourceLength = this.get('sourceArray.length');58 return Math.min(sourceLength, endIndex + indexMargin);59 }),60 61 _startChanged: observer('_start', function _startChanged() {62 const {63 _startCache,64 _start,65 } = this.getProperties(66 '_startCache',67 '_start'68 );69 70 if (_startCache !== undefined && _start !== _startCache) {71 let removeAmt = 0;72 let addAmt = 0;73 if (_start > _startCache) {74 removeAmt = _start - _startCache;75 } else {76 addAmt = _startCache - _start;77 }78 this.arrayContentDidChange(_start, removeAmt, addAmt);79 }80 81 this.set('_startCache', _start);82 }),83 84 _endChanged: observer('_end', function _endChanged() {85 const {86 _endCache,87 _end,88 } = this.getProperties(89 '_endCache',90 '_end'91 );92 if (_endCache !== undefined && _end !== _endCache) {93 let removeAmt = 0;94 let addAmt = 0;95 if (_end > _endCache) {96 addAmt = _end - _endCache;97 } else {98 removeAmt = _endCache - _end;99 }100 this.arrayContentDidChange(_endCache - removeAmt, removeAmt, addAmt);101 }102 103 this.set('_endCache', _end);104 }),105 106 /**107 * @override 108 */109 replace(idx, amt, objects) {110 const sourceArray = this.get('sourceArray');111 return sourceArray.replace(this._translateIndex(idx), amt, objects);112 },113 114 /**115 * @override116 */117 objectAt(idx) {118 const sourceArray = this.get('sourceArray');119 if (sourceArray) {120 return sourceArray.objectAt(this._translateIndex(idx));121 }122 },123 124 /**125 * @override 126 */127 length: computed('_start', '_end', function () {128 const {129 _start,130 _end,131 } = this.getProperties(132 '_start',133 '_end'134 );135 return _end - _start;136 }),137 _arrayContentChange(startIdx, removeAmt, addAmt, fun) {138 const {139 _start,140 _end,141 } = this.getProperties(142 '_start',143 '_end'144 );145 if (_start <= startIdx && startIdx <= _end) {146 const sliceStartIdx = startIdx - _start;147 const sliceRemoveAmt = Math.min(_end, sliceStartIdx + removeAmt) - sliceStartIdx;148 const sliceAddAmt = Math.min(_end, sliceStartIdx + addAmt) - sliceStartIdx;149 return fun.bind(this)(sliceStartIdx, sliceRemoveAmt, sliceAddAmt);150 } else {151 return this;152 }153 },154 155 /**156 * @override157 */158 arrayContentWillChange(startIdx, removeAmt, addAmt) {159 return this._arrayContentChange(startIdx, removeAmt, addAmt, this._super);160 },161 162 /**163 * @override164 */165 arrayContentDidChange(startIdx, removeAmt, addAmt) {166 return this._arrayContentChange(startIdx, removeAmt, addAmt, this._super);167 },168 169 _translateIndex(index) {170 const {171 _start,172 _end,173 } = this.getProperties(174 '_start',175 '_end'176 );177 const translatedIndex = _start + index;178 return translatedIndex > _end ? -1 : translatedIndex;179 },180 181 init() {182 this._super(...arguments);183 // activate observers184 this.getProperties('_start', '_end');185 this._startChanged();186 this._endChanged();187 },...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run locust automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful