How to use strip method in Cypress

Best JavaScript code snippet using cypress

md-slider-preview.js

Source:md-slider-preview.js Github

copy

Full Screen

1/*------------------------------------------------------------------------2 # MD Slider - March 18, 2013 xxxxxxx3 # ------------------------------------------------------------------------4 # Websites: http://www.megadrupal.com - Email: info@megadrupal.com5 --------------------------------------------------------------------------*/6(function ($) {7 $.fn.mdSlider = function(options) {8 var defaults = {9 className: 'md-slide-wrap',10 itemClassName: 'md-slide-item',11 transitions: 'strip-down-left', // name of transition effect (fade, scrollLeft, scrollRight, scrollHorz, scrollUp, scrollDown, scrollVert)12 transitionsSpeed: 800, // speed of the transition (millisecond)13 width: 990, // responsive = false: this appear as container width; responsive = true: use for scale ;fullwidth = true: this is effect zone width14 height: 420, // container height15 responsive: true,16 fullwidth: true,17 styleBorder: 0, // Border style, from 1 - 9, 0 to disable18 styleShadow: 0, // Dropshadow style, from 1 - 5, 0 to disable19 posBullet: 2, // Bullet position, from 1 to 6, default is 520 posThumb: 1, // Thumbnail position, from 1 to 5, default is 121 stripCols: 20,22 stripRows: 10,23 slideShowDelay: 6000, // stop time for each slide item (millisecond)24 slideShow: true,25 loop: false,26 pauseOnHover: false,27 showLoading: true, // Show/hide loading bar28 loadingPosition: 'bottom', // choose your loading bar position (top, bottom)29 showArrow: true, // show/hide next, previous arrows30 showBullet: true,31 showThumb: true, // Show thumbnail, if showBullet = true and showThumb = true, thumbnail will be shown when you hover bullet navigation32 enableDrag: true, // Enable mouse drag33 touchSensitive: 50,34 onEndTransition: function() { }, //this callback is invoked when the transition effect ends35 onStartTransition: function() { } //this callback is invoked when the transition effect starts36 };37 options = $.extend({}, defaults, options);38 var self= $(this), slideItems = [], oIndex, activeIndex = -1, numItem = 0, slideWidth, slideHeight, lock = true,39 wrap,40 hoverDiv,41 hasTouch,42 arrowButton,43 buttons,44 loadingBar,45 timerGlow,46 slideThumb,47 minThumbsLeft = 0,48 touchstart,49 mouseleft,50 thumbsDrag = false,51 slideShowDelay = 0,52 play = false,53 pause = false,54 timer,55 step = 0;56 // init57 function init() {58 self.addClass("loading-image"); 59 self.wrap('<div class="md-slide-fullwidth"><div class="md-item-wrap"></div></div>');60 hoverDiv = self.parent();61 wrap = hoverDiv.parent();62 slideWidth = options.responsive ? self.width() : options.width;63 slideHeight = options.height;64 self.css({width: slideWidth, height: slideHeight});65 slideItems = [];66 self.find('.' + options.itemClassName).each(function (index) {67 numItem++;68 slideItems[index] = $(this);69 if(index > 0)70 $(this).hide();71 });72 }73 var lock = false;74 function slide(index) {75 step = 0;76 slideShowDelay = slideItems[index].data("timeout") ? slideItems[index].data("timeout") : options.slideShowDelay;77 if (index != activeIndex) {78 oIndex = activeIndex;79 activeIndex = index;80 if (slideItems[oIndex]) {81 var fx = options.transitions;82 //Generate random transition83 if (options.transitions.toLowerCase() == 'random') {84 var transitions = new Array(85 'slit-horizontal-left-top',86 'slit-horizontal-top-right',87 'slit-horizontal-bottom-up',88 'slit-vertical-down',89 'slit-vertical-up',90 'strip-up-right',91 'strip-up-left',92 'strip-down-right',93 'strip-down-left',94 'strip-left-up',95 'strip-left-down',96 'strip-right-up',97 'strip-right-down',98 'strip-right-left-up',99 'strip-right-left-down',100 'strip-up-down-right',101 'strip-up-down-left',102 'left-curtain',103 'right-curtain',104 'top-curtain',105 'bottom-curtain',106 'slide-in-right',107 'slide-in-left',108 'slide-in-up',109 'slide-in-down');110 fx = transitions[Math.floor(Math.random() * (transitions.length + 1))];111 if (fx == undefined) fx = 'fade';112 fx = $.trim(fx.toLowerCase());113 }114 //Run random transition from specified set (eg: effect:'strip-left-fade,right-curtain')115 if (options.transitions.indexOf(',') != -1) {116 var transitions = options.transitions.split(',');117 fx = transitions[Math.floor(Math.random() * (transitions.length))];118 if (fx == undefined) fx = 'fade';119 fx = $.trim(fx.toLowerCase());120 }121 //Custom transition as defined by "data-transition" attribute122 if (slideItems[activeIndex].data('transition')) {123 var transitions = slideItems[activeIndex].data('transition').split(',');124 fx = transitions[Math.floor(Math.random() * (transitions.length))];125 fx = $.trim(fx.toLowerCase());126 }127 if(!(this.support = Modernizr.csstransitions && Modernizr.csstransforms3d) && (fx == 'slit-horizontal-left-top' || fx == 'slit-horizontal-top-right' || fx == 'slit-horizontal-bottom-up' || fx == 'slit-vertical-down' || fx == 'slit-vertical-up')) {128 fx = 'fade';129 }130 lock = true;131 runTransition(fx);132 } else {133 slideItems[activeIndex].css({top:0, left:0}).show();134 lock = false;135 }136 }137 }138 function setTimer() {139 slide(0);140 timer = setInterval(next, 40);141 }142 function next() {143 if(lock) return false;144 step += 40;145 if(step > slideShowDelay) {146 slideNext();147 }148 }149 function slideNext() {150 if(lock) return false;151 var index = activeIndex;152 index++;153 if(index >= numItem && options.loop) {154 index = 0;155 slide(index);156 } else if(index < numItem) {157 slide(index);158 }159 }160 function slidePrev() {161 if(lock) return false;162 var index = activeIndex;163 index--;164 if(index < 0 && options.loop) {165 index = numItem - 1;166 slide(index);167 } else if(index >= 0) {168 slide(index);169 }170 }171 172 //When Animation finishes173 function transitionEnd() {174 options.onEndTransition.call(self);175 $('.md-strips-container', self).remove();176 slideItems[oIndex].hide();177 slideItems[activeIndex].show();178 lock = false;179 }180 // Add strips181 function addStrips(vertical, opts) {182 var strip,183 opts = (opts) ? opts : options;;184 var stripsContainer = $('<div class="md-strips-container"></div>');185 var stripWidth = Math.round(slideWidth / opts.strips),186 stripHeight = Math.round(slideHeight / opts.strips),187 $image = $(".md-mainimg img", slideItems[activeIndex]);188 for (var i = 0; i < opts.strips; i++) {189 var top = ((vertical) ? (stripHeight * i) + 'px' : '0px'),190 left = ((vertical) ? '0px' : (stripWidth * i) + 'px'),191 width, height;192 if (i == opts.strips - 1) {193 width = ((vertical) ? '0px' : (slideWidth - (stripWidth * i)) + 'px'),194 height = ((vertical) ? (slideHeight - (stripHeight * i)) + 'px' : '0px');195 } else {196 width = ((vertical) ? '0px' : stripWidth + 'px'),197 height = ((vertical) ? stripHeight + 'px' : '0px');198 }199 strip = $('<div class="mdslider-strip"></div>').css({200 width: width,201 height: height,202 top: top,203 left: left,204 opacity: 0205 }).append($image.clone().css({206 marginLeft: vertical ? 0 : -(i * stripWidth) + "px",207 marginTop: vertical ? -(i * stripHeight) + "px" : 0208 }));209 stripsContainer.append(strip);210 }211 self.append(stripsContainer);212 }213 // Add strips214 function addTiles(x, y, index) {215 var tile;216 var stripsContainer = $('<div class="md-strips-container"></div>');217 var tileWidth = slideWidth / x,218 tileHeight = slideHeight / y,219 $image = $(".md-mainimg img", slideItems[index]);220 for(var i = 0; i < y; i++) {221 for(var j = 0; j < x; j++) {222 var top = (tileHeight * i) + 'px',223 left = (tileWidth * j) + 'px';224 tile = $('<div class="mdslider-tile"/>').css({225 width: tileWidth,226 height: tileHeight,227 top: top,228 left: left229 }).append($image.clone().css({230 marginLeft: "-" + left,231 marginTop: "-" + top232 }));233 stripsContainer.append(tile);234 }235 }236 self.append(stripsContainer);237 }238 // Add strips239 function addStrips2() {240 var strip,241 images = [$(".md-mainimg img", slideItems[oIndex]), $(".md-mainimg img", slideItems[activeIndex])];242 var stripsContainer = $('<div class="md-strips-container"></div>');243 for (var i = 0; i < 2; i++) {244 strip = $('<div class="mdslider-strip"></div>').css({245 width: slideWidth,246 height: slideHeight247 }).append(images[i].clone());248 stripsContainer.append(strip);249 }250 self.append(stripsContainer);251 }252 // Add strips253 function addSlits(fx) {254 var $stripsContainer = $('<div class="md-strips-container ' + fx + '"></div>'),255 $image = $(".md-mainimg img", slideItems[oIndex]),256 $div1 = $('<div class="mdslider-slit"/>').append($image.clone()),257 $div2 = $('<div class="mdslider-slit"/>').append($image.clone().css("top", "-=" + (slideHeight/2) + "px"));258 if(fx == "slit-vertical-down" || fx == "slit-vertical-up")259 $div2 = $('<div class="mdslider-slit"/>').append($image.clone().css("left", "-=" + (slideWidth/2) + "px"));260 $stripsContainer.append($div1).append($div2);261 self.append($stripsContainer);262 }263 function runTransition(fx) {264 switch (fx) {265 case 'slit-horizontal-left-top':266 case 'slit-horizontal-top-right':267 case 'slit-horizontal-bottom-up':268 case 'slit-vertical-down':269 case 'slit-vertical-up':270 addSlits(fx);271 $(".md-object", slideItems[activeIndex]).hide();272 slideItems[oIndex].hide();273 slideItems[activeIndex].show();274 var slice1 = $('.mdslider-slit', self).first(),275 slice2 = $('.mdslider-slit', self).last();276 var transitionProp = {277 'transition' : 'all ' + options.transitionsSpeed + 'ms ease-in-out',278 '-webkit-transition' : 'all ' + options.transitionsSpeed + 'ms ease-in-out',279 '-moz-transition' : 'all ' + options.transitionsSpeed + 'ms ease-in-out',280 '-ms-transition' : 'all ' + options.transitionsSpeed + 'ms ease-in-out'281 };282 $('.mdslider-slit', self).css(transitionProp);283 setTimeout( function() {284 slice1.addClass("md-trans-elems-1");285 slice2.addClass("md-trans-elems-2");286 }, 50 );287 setTimeout(function() {288 options.onEndTransition.call(self);289 $('.md-strips-container', self).remove();290 lock = false;291 }, options.transitionsSpeed);292 break;293 case 'strip-up-right':294 case 'strip-up-left':295 addTiles(options.stripCols, 1, activeIndex);296 var strips = $('.mdslider-tile', self),297 timeStep = options.transitionsSpeed / options.stripCols / 2,298 speed = options.transitionsSpeed / 2;299 if (fx == 'strip-up-right') strips = $('.mdslider-tile', self).reverse();300 strips.css({301 height: '1px',302 bottom: '0px',303 top: "auto"304 });305 strips.each(function (i) {306 var strip = $(this);307 setTimeout(function () {308 strip.animate({309 height: '100%',310 opacity: '1.0'311 }, speed, 'easeInOutQuart', function () {312 if (i == options.stripCols - 1) transitionEnd();313 });314 }, i * timeStep);315 });316 break;317 case 'strip-down-right':318 case 'strip-down-left':319 addTiles(options.stripCols, 1, activeIndex);320 var strips = $('.mdslider-tile', self),321 timeStep = options.transitionsSpeed / options.stripCols / 2,322 speed = options.transitionsSpeed / 2;323 if (fx == 'strip-down-right') strips = $('.mdslider-tile', self).reverse();324 strips.css({325 height: '1px',326 top: '0px',327 bottom: "auto"328 });329 strips.each(function (i) {330 var strip = $(this);331 setTimeout(function () {332 strip.animate({333 height: '100%',334 opacity: '1.0'335 }, speed, 'easeInOutQuart', function () {336 if (i == options.stripCols - 1) transitionEnd();337 });338 }, i * timeStep);339 });340 break;341 case 'strip-left-up':342 case 'strip-left-down':343 addTiles(1, options.stripRows, activeIndex);344 var strips = $('.mdslider-tile', self),345 timeStep = options.transitionsSpeed / options.stripRows / 2,346 speed = options.transitionsSpeed / 2;347 if (fx == 'strip-left-up') strips = $('.mdslider-tile', self).reverse();348 strips.css({349 width: '1px',350 left: '0px',351 right: "auto"352 });353 strips.each(function (i) {354 var strip = $(this);355 setTimeout(function () {356 strip.animate({357 width: '100%',358 opacity: '1.0'359 }, speed, 'easeInOutQuart', function () {360 if (i == options.stripRows - 1) transitionEnd();361 });362 }, i * timeStep);363 });364 break;365 case 'strip-right-up':366 case 'strip-right-down':367 addTiles(1, options.stripRows, activeIndex);368 var strips = $('.mdslider-tile', self),369 timeStep = options.transitionsSpeed / options.stripRows / 2,370 speed = options.transitionsSpeed / 2;371 if (fx == 'strip-left-right-up') strips = $('.mdslider-tile', self).reverse();372 strips.css({373 width: '1px',374 left: 'auto',375 right: "1px"376 });377 strips.each(function (i) {378 var strip = $(this);379 setTimeout(function () {380 strip.animate({381 width: '100%',382 opacity: '1.0'383 }, speed, 'easeInOutQuart', function () {384 if (i == options.stripRows - 1) transitionEnd();385 });386 }, i * timeStep);387 });388 break;389 case 'strip-right-left-up':390 case 'strip-right-left-down':391 addTiles(1, options.stripRows, oIndex);392 slideItems[oIndex].hide();393 slideItems[activeIndex].show();394 var strips = $('.mdslider-tile', self),395 timeStep = options.transitionsSpeed / options.stripRows,396 speed = options.transitionsSpeed / 2;397 if (fx == 'strip-right-left-up') strips = $('.mdslider-tile', self).reverse();398 strips.filter(':odd').css({399 width: '100%',400 right: '0px',401 left: "auto",402 opacity: 1403 }).end().filter(':even').css({404 width: '100%',405 right: 'auto',406 left: "0px",407 opacity: 1408 });;409 strips.each(function (i) {410 var strip = $(this);411 var css = (i%2 == 0) ? {left: '-50%',opacity: '0'} : {right: '-50%', opacity: '0'};412 setTimeout(function () {413 strip.animate(css, speed, 'easeOutQuint', function () {414 if (i == options.stripRows - 1) {415 options.onEndTransition.call(self);416 $('.md-strips-container', self).remove();417 lock = false;418 }419 });420 }, i * timeStep);421 });422 break;423 case 'strip-up-down-right':424 case 'strip-up-down-left':425 addTiles(options.stripCols, 1, oIndex);426 slideItems[oIndex].hide();427 slideItems[activeIndex].show();428 var strips = $('.mdslider-tile', self),429 timeStep = options.transitionsSpeed / options.stripCols / 2 ,430 speed = options.transitionsSpeed / 2;431 if (fx == 'strip-up-down-right') strips = $('.mdslider-tile', self).reverse();432 strips.filter(':odd').css({433 height: '100%',434 bottom: '0px',435 top: "auto",436 opacity: 1437 }).end().filter(':even').css({438 height: '100%',439 bottom: 'auto',440 top: "0px",441 opacity: 1442 });;443 strips.each(function (i) {444 var strip = $(this);445 var css = (i%2 == 0) ? {top: '-50%',opacity: 0} : {bottom: '-50%', opacity: 0};446 setTimeout(function () {447 strip.animate(css, speed, 'easeOutQuint', function () {448 if (i == options.stripCols - 1) {449 options.onEndTransition.call(self);450 $('.md-strips-container', self).remove();451 lock = false;452 }453 });454 }, i * timeStep);455 });456 break;457 case 'left-curtain':458 addTiles(options.stripCols, 1, activeIndex);459 var strips = $('.mdslider-tile', self),460 width = slideWidth / options.stripCols,461 timeStep = options.transitionsSpeed / options.stripCols / 2;462 strips.each(function (i) {463 var strip = $(this);464 strip.css({left: width * i, width: 0, opacity: 0});465 setTimeout(function () {466 strip.animate({467 width: width,468 opacity: '1.0'469 }, options.transitionsSpeed / 2, function () {470 if (i == options.stripCols - 1) transitionEnd();471 });472 }, timeStep * i);473 });474 break;475 case 'right-curtain':476 addTiles(options.stripCols, 1, activeIndex);477 var strips = $('.mdslider-tile', self).reverse(),478 width = slideWidth / options.stripCols,479 timeStep = options.transitionsSpeed / options.stripCols / 2;480 strips.each(function (i) {481 var strip = $(this);482 strip.css({right: width * i, left: "auto", width: 0, opacity: 0});483 setTimeout(function () {484 strip.animate({485 width: width,486 opacity: '1.0'487 }, options.transitionsSpeed / 2, function () {488 if (i == options.stripCols - 1) transitionEnd();489 });490 }, timeStep * i);491 });492 break;493 case 'top-curtain':494 addTiles(1, options.stripRows, activeIndex);495 var strips = $('.mdslider-tile', self),496 height = slideHeight / options.stripRows,497 timeStep = options.transitionsSpeed / options.stripRows / 2;498 strips.each(function (i) {499 var strip = $(this);500 strip.css({top: height * i, height: 0, opacity: 0});501 setTimeout(function () {502 strip.animate({503 height: height,504 opacity: '1.0'505 }, options.transitionsSpeed / 2, function () {506 if (i == options.stripRows - 1) transitionEnd();507 });508 }, timeStep * i);509 });510 break;511 case 'bottom-curtain':512 addTiles(1, options.stripRows, activeIndex);513 var strips = $('.mdslider-tile', self).reverse(),514 height = slideHeight / options.stripRows,515 timeStep = options.transitionsSpeed / options.stripRows / 2;516 strips.each(function (i) {517 var strip = $(this);518 strip.css({bottom: height * i, height: 0, opacity: 0});519 setTimeout(function () {520 strip.animate({521 height: height,522 opacity: '1.0'523 }, options.transitionsSpeed / 2, function () {524 if (i == options.stripRows - 1) transitionEnd();525 });526 }, timeStep * i);527 });528 break;529 case 'slide-in-right':530 var i = 0;531 addStrips2();532 var strips = $('.mdslider-strip', self);533 strips.each(function() {534 strip = $(this);535 var left = i * slideWidth;536 strip.css({537 left: left538 });539 strip.animate({540 left: left - slideWidth541 }, options.transitionsSpeed, function () {542 transitionEnd();543 });544 i++;545 });546 break;547 case 'slide-in-left':548 var i = 0;549 addStrips2();550 var strips = $('.mdslider-strip', self);551 strips.each(function() {552 strip = $(this);553 var left = -i * slideWidth;554 strip.css({555 left: left556 });557 strip.animate({558 left: slideWidth + left559 }, (options.transitionsSpeed * 2), function () {560 transitionEnd();561 });562 i++;563 });564 break;565 case 'slide-in-up':566 var i = 0;567 addStrips2();568 var strips = $('.mdslider-strip', self);569 strips.each(function() {570 strip = $(this);571 var top = i * slideHeight;572 strip.css({573 top: top574 });575 strip.animate({576 top: top - slideHeight577 }, options.transitionsSpeed, function () {578 transitionEnd();579 });580 i++;581 });582 break;583 case 'slide-in-down':584 var i = 0;585 addStrips2();586 var strips = $('.mdslider-strip', self);587 strips.each(function() {588 strip = $(this);589 var top = -i * slideHeight;590 strip.css({591 top: top592 });593 strip.animate({594 top: slideHeight + top595 }, options.transitionsSpeed, function () {596 transitionEnd();597 });598 i++;599 });600 break;601 case 'fade':602 default:603 var opts = {604 strips: 1605 };606 addStrips(false, opts);607 var strip = $('.mdslider-strip:first', self);608 strip.css({609 'height': '100%',610 'width': slideWidth611 });612 if (fx == 'slide-in-right') strip.css({613 'height': '100%',614 'width': slideWidth,615 'left': slideWidth + 'px',616 'right': ''617 });618 else if (fx == 'slide-in-left') strip.css({619 'left': '-' + slideWidth + 'px'620 });621 strip.animate({622 left: '0px',623 opacity: 1624 }, options.transitionsSpeed, function () {625 transitionEnd();626 });627 break;628 }629 }630 function slideReady() {631 self.removeClass("loading-image");632 setTimer();633 }634 635 init();636 slideReady();637 }638 $.fn.reverse = [].reverse;...

Full Screen

Full Screen

Prims.js

Source:Prims.js Github

copy

Full Screen

1// 무슨기능인지 x s2import ScratchJr from '../ScratchJr';3import ScratchAudio from '../../utils/ScratchAudio';4import Grid from '../ui/Grid';5import Vector from '../../geom/Vector';6import {gn} from '../../utils/lib';7let tinterval = 1;8let hopList = [-48, -30, -22, -14, -6, 0, 6, 14, 22, 30, 48];9export default class Prims {10 static get hopList () {11 return hopList;12 }13 static init () {14 Prims.table = {};15 Prims.table.done = Prims.Done;16 Prims.table.missing = Prims.Ignore;17 Prims.table.onflag = Prims.Ignore;18 Prims.table.onmessage = Prims.Ignore;19 Prims.table.onclick = Prims.Ignore;20 Prims.table.ontouch = Prims.OnTouch;21 Prims.table.onchat = Prims.Ignore;22 Prims.table.repeat = Prims.Repeat;23 Prims.table.forward = Prims.Forward;24 Prims.table.back = Prims.Back;25 Prims.table.up = Prims.Up;26 Prims.table.down = Prims.Down;27 Prims.table.left = Prims.Left;28 Prims.table.right = Prims.Right;29 Prims.table.home = Prims.Home;30 Prims.table.setspeed = Prims.SetSpeed;31 Prims.table.message = Prims.Message;32 Prims.table.setcolor = Prims.SetColor;33 Prims.table.bigger = Prims.Bigger;34 Prims.table.smaller = Prims.Smaller;35 Prims.table.wait = Prims.Wait;36 Prims.table.caretcmd = Prims.Ignore;37 Prims.table.caretstart = Prims.Ignore;38 Prims.table.caretend = Prims.Ignore;39 Prims.table.caretrepeat = Prims.Ignore;40 Prims.table.gotopage = Prims.GotoPage;41 Prims.table.endstack = Prims.DoNextBlock;42 Prims.table.stopall = Prims.StopAll;43 Prims.table.stopmine = Prims.StopMine;44 Prims.table.forever = Prims.Forever;45 Prims.table.hop = Prims.Hop;46 Prims.table.show = Prims.Show;47 Prims.table.hide = Prims.Hide;48 Prims.table.playsnd = Prims.playSound;49 Prims.table.playusersnd = Prims.playSound;50 Prims.table.grow = Prims.Grow;51 Prims.table.shrink = Prims.Shrink;52 Prims.table.same = Prims.Same;53 Prims.table.say = Prims.Say;54 //LED 블록 제어 55 Prims.table.redled = Prims.Redled;56 Prims.table.greenled = Prims.Greenled;57 Prims.table.blueled = Prims.Blueled;58 Prims.table.ledoff = Prims.LED_off;59 //모터 블록 제어 60 Prims.table.up = Prims.MotorUp;61 Prims.table.down = Prims.MotorDown;62 Prims.table.right = Prims.MotorRight;63 Prims.table.left = Prims.MotorLeft;64 Prims.table.motorstop = Prims.Motorstop;65 //스피커 블록 제어66 Prims.table.speaker = Prims.Speaker;67 }68 static MotorUp(strip)69 {70 strip.waitTimer = tinterval * 10;71 window.location = "jscall://MotorUp"; 72 strip.thisblock = strip.thisblock.next;73 }74 static Motorstop(strip)75 {76 strip.waitTimer = tinterval * 10;77 window.location = "jscall://Motorstop"; 78 strip.thisblock = strip.thisblock.next;79 }80 static MotorDown(strip)81 {82 strip.waitTimer = tinterval * 10;83 window.location = "jscall://MotorDown"; 84 strip.thisblock = strip.thisblock.next;85 }86 static MotorRight(strip)87 {88 strip.waitTimer = tinterval * 10;89 window.location = "jscall://MotorRight"; 90 strip.thisblock = strip.thisblock.next;91 }92 static MotorLeft(strip)93 {94 strip.waitTimer = tinterval * 10;95 window.location = "jscall://MotorLeft"; 96 strip.thisblock = strip.thisblock.next;97 }98 static Speaker(strip)99 {100 strip.waitTimer = tinterval * 10;101 window.location = "jscall://Speaker"; 102 strip.thisblock = strip.thisblock.next;103 }104 static Redled(strip)105 {106 console.log("-------------------------------------") 107 console.log("LED",strip)108 console.log("-------------------------------------")109 strip.waitTimer = tinterval * 10;110 window.location = "jscall://RLEDON"; 111 112 113 strip.thisblock = strip.thisblock.next;114 }115 static Greenled (strip)116 {117 strip.waitTimer = tinterval * 10;118 119 window.location = "jscall://GLEDON"; 120 strip.thisblock = strip.thisblock.next; 121 }122 static Blueled (strip)123 {124 strip.waitTimer = tinterval * 10;125 126 window.location = "jscall://BLEDON"; 127 strip.thisblock = strip.thisblock.next; 128 }129 static LED_off(strip)130 {131 strip.waitTimer = tinterval * 10;132 console.log("-------------------------------------") 133 console.log("LEDOFF",strip)134 console.log("-------------------------------------")135 window.location = "jscall://LEDOFF";136 strip.thisblock = strip.thisblock.next;137 }138 static Done (strip) {139 if (strip.oldblock != null) {140 strip.oldblock.unhighlight();141 }142 strip.oldblock = null;143 strip.isRunning = false;144 }145 static setTime (strip) {146 strip.time = (new Date()) - 0;147 }148 static showTime () {149 //var time = ((new Date()) - strip.time) / 1000;150 // ScratchJr.log (strip.thisblock.blocktype, time, "sec") ;151 }152 static DoNextBlock (strip) {153 strip.waitTimer = tinterval * 10;154 strip.thisblock = strip.thisblock.next;155 }156 static StopAll () {157 ScratchJr.stopStrips();158 }159 static StopMine (strip) {160 console.log("stopMind slslslslsls")161 var spr = strip.spr;162 for (var i = 0; i < ScratchJr.runtime.threadsRunning.length; i++) {163 if ((ScratchJr.runtime.threadsRunning[i].spr == spr)164 && (ScratchJr.runtime.threadsRunning[i].thisblock != strip.thisblock)) {165 ScratchJr.runtime.threadsRunning[i].stop(true);166 }167 }168 strip.thisblock = strip.thisblock.next;169 ScratchJr.runtime.yield = true;170 }171 static playSound (strip) {172 var b = strip.thisblock;173 var name = b.getSoundName(strip.spr.sounds);174 // console.log ('playSound', name);175 if (!strip.audio) {176 var snd = ScratchAudio.projectSounds[name];177 if (!snd) {178 strip.thisblock = strip.thisblock.next;179 return;180 }181 strip.audio = snd;182 snd.play();183 // console.log ("playSound", snd, strip.audio, snd.source.playbackState);184 }185 if (strip.audio && strip.audio.done()) {186 strip.audio.clear();187 strip.thisblock = strip.thisblock.next;188 strip.audio = undefined;189 }190 strip.waitTimer = tinterval * 4;191 }192 193 static Say (strip) {194 var b = strip.thisblock;195 var s = strip.spr;196 var str = b.getArgValue();197 if (strip.count < 0) {198 strip.count = Math.max(30, Math.round(str.length / 8) * 30); // 7 chars per seconds;199 s.openBalloon(str);200 Prims.setTime(strip);201 } else {202 var count = strip.count;203 count--;204 if (count < 0) {205 strip.count = -1;206 s.closeBalloon();207 Prims.showTime(strip);208 strip.thisblock = strip.thisblock.next;209 } else {210 strip.waitTimer = tinterval;211 strip.count = count;212 }213 }214 }215 static GotoPage (strip) {216 var b = strip.thisblock;217 var n = Number(b.getArgValue());218 if (strip.count < 0) {219 strip.count = 2; // delay for a 10th of a second220 Prims.setTime(strip);221 } else {222 var count = strip.count;223 count--;224 if (count < 0) {225 strip.count = -1;226 Prims.showTime(strip);227 ScratchJr.stage.gotoPage(n);228 } else {229 strip.waitTimer = tinterval;230 strip.count = count;231 }232 }233 }234 static Forever (strip) {235 strip.thisblock = strip.firstBlock.aStart ? strip.firstBlock.next : strip.firstBlock;236 ScratchJr.runtime.yield = true;237 }238 static Repeat (strip) {239 var b = strip.thisblock;240 var n = Number(b.getArgValue());241 if (n < 1) {242 n = 1;243 }244 if (b.repeatCounter < 0) {245 b.repeatCounter = n;246 }247 if (b.repeatCounter == 0) {248 b.repeatCounter = -1;249 strip.thisblock = strip.thisblock.next;250 strip.waitTimer = tinterval;251 } else {252 strip.stack.push(strip.thisblock);253 b.repeatCounter--;254 strip.thisblock = strip.thisblock.inside;255 ScratchJr.runtime.yield = true;256 }257 }258 static Ignore (strip) {259 strip.thisblock = strip.thisblock.next;260 }261 static Wait (strip) {262 console.log("aalalalalal")263 var n = strip.thisblock.getArgValue();264 strip.waitTimer = Math.round(n * 3.125); // thenth of a second265 Prims.setTime(strip);266 strip.thisblock = strip.thisblock.next;267 }268 static Home (strip) {269 var spr = strip.spr;270 spr.goHome();271 strip.waitTimer = tinterval;272 strip.thisblock = strip.thisblock.next;273 }274 static SetSpeed (strip) 275 {276 console.log("steopSdkdkdkdkdkdpeed");277 var s = strip.spr;278 var num = Number(strip.thisblock.getArgValue()); // 0 - 1 - 2279 s.speed = Math.pow(2, num);280 strip.waitTimer = tinterval;281 strip.thisblock = strip.thisblock.next;282 }283 static Hop (strip) {284 if (strip.count < 0) { // setup the hop285 strip.count = hopList.length;286 Prims.setTime(strip);287 }288 Prims.hopTo(strip);289 }290 static hopTo (strip) {291 var s = strip.spr;292 var b = strip.thisblock;293 var n = Number(b.getArgValue());294 var count = strip.count;295 count--;296 if (count < 0) {297 strip.count = -1;298 strip.vector = {299 x: 0,300 y: 0301 };302 Prims.showTime(strip);303 strip.thisblock = strip.thisblock.next;304 } else {305 strip.vector = {306 x: 0,307 y: hopList[count]308 };309 var dy = s.ycoor - strip.vector.y / 5 * n;310 if (dy < 0) {311 dy = 0;312 }313 if (dy >= (360 - Grid.size)) {314 dy = (360 - Grid.size);315 }316 s.setPos(s.xcoor + strip.vector.x, dy);317 strip.waitTimer = tinterval + Math.floor(Math.pow(2, 2 - Math.floor(s.speed / 2)) / 2);318 strip.count = count;319 }320 }321 static Down (strip) {322 var num = Number(strip.thisblock.getArgValue()) * 24;323 var distance = Math.abs(num);324 if (num == 0) {325 strip.thisblock = strip.thisblock.next;326 strip.waitTimer = tinterval;327 strip.distance = -1;328 strip.vector = {329 x: 0,330 y: 0331 };332 return;333 }334 if (num == 0) {335 strip.distance = 0;336 } else if (strip.distance < 0) {337 strip.distance = distance;338 strip.vector = {339 x: 0,340 y: 2341 };342 Prims.setTime(strip);343 }344 Prims.moveAtSpeed(strip);345 }346 static Up (strip) {347 var num = Number(strip.thisblock.getArgValue()) * 24;348 var distance = Math.abs(num);349 if (num == 0) {350 strip.thisblock = strip.thisblock.next;351 strip.waitTimer = tinterval;352 strip.distance = -1;353 strip.vector = {354 x: 0,355 y: 0356 };357 return;358 } else if (strip.distance < 0) {359 strip.distance = distance;360 strip.vector = {361 x: 0,362 y: -2363 };364 Prims.setTime(strip);365 }366 Prims.moveAtSpeed(strip);367 }368 static Forward (strip) {369 var s = strip.spr;370 var num = Number(strip.thisblock.getArgValue()) * 24;371 var distance = Math.abs(num);372 if (s.flip) {373 s.flip = false;374 s.render();375 }376 if (num == 0) {377 strip.thisblock = strip.thisblock.next;378 strip.waitTimer = tinterval * Math.pow(2, 2 - Math.floor(s.speed / 2));379 strip.vector = {380 x: 0,381 y: 0382 };383 strip.distance = -1;384 return;385 } else if (strip.distance < 0) {386 strip.distance = distance;387 strip.vector = {388 x: 2,389 y: 0390 };391 Prims.setTime(strip);392 }393 Prims.moveAtSpeed(strip);394 }395 static Back (strip) {396 var s = strip.spr;397 var num = Number(strip.thisblock.getArgValue()) * 24;398 var distance = Math.abs(num);399 if (!s.flip) {400 s.flip = true;401 s.render();402 }403 if (num == 0) {404 strip.thisblock = strip.thisblock.next;405 strip.vector = {406 x: 0,407 y: 0408 };409 strip.waitTimer = tinterval * Math.pow(2, 2 - Math.floor(s.speed / 2));410 return;411 }412 if (num == 0) {413 strip.distance = 0;414 } else if (strip.distance < 0) {415 strip.distance = distance;416 strip.vector = {417 x: -2,418 y: 0419 };420 Prims.setTime(strip);421 }422 Prims.moveAtSpeed(strip);423 }424 static moveAtSpeed (strip) {425 var s = strip.spr;426 var distance = strip.distance;427 var num = Number(strip.thisblock.getArgValue()) * 12; // 1/2 cell size since vector is double428 var vector = Vector.scale(strip.vector, s.speed * Math.abs(num) / num);429 distance -= Math.abs(Vector.len(vector));430 if (distance < 0) {431 vector = Vector.scale(strip.vector, strip.distance);432 s.setPos(s.xcoor + vector.x, s.ycoor + vector.y);433 strip.distance = -1;434 strip.vector = {435 x: 0,436 y: 0437 };438 Prims.showTime(strip);439 strip.thisblock = strip.thisblock.next;440 } else {441 s.setPos(s.xcoor + vector.x, s.ycoor + vector.y);442 strip.waitTimer = tinterval;443 strip.distance = distance;444 }445 }446 static Right (strip) {447 var s = strip.spr;448 var num = Number(strip.thisblock.getArgValue()) * 30;449 if (strip.count < 0) {450 strip.count = Math.floor(Math.abs(num) / s.speed * 0.25);451 strip.angleStep = s.speed * 4 * Math.abs(num) / num;452 strip.finalAngle = s.angle + num;453 strip.finalAngle = strip.finalAngle % 360;454 if (strip.finalAngle < 0) {455 strip.finalAngle += 360;456 }457 if (strip.finalAngle > 360) {458 strip.finalAngle -= 360;459 }460 Prims.setTime(strip);461 }462 Prims.turning(strip);463 }464 static Left (strip) {465 var s = strip.spr;466 var num = Number(strip.thisblock.getArgValue()) * 30;467 if (strip.count < 0) {468 strip.count = Math.floor(Math.abs(num) / s.speed * 0.25);469 strip.angleStep = -s.speed * 4 * Math.abs(num) / num;470 strip.finalAngle = s.angle - num;471 strip.finalAngle = strip.finalAngle % 360;472 if (strip.finalAngle < 0) {473 strip.finalAngle += 360;474 }475 if (strip.finalAngle > 360) {476 strip.finalAngle -= 360;477 }478 Prims.setTime(strip);479 }480 Prims.turning(strip);481 }482 static turning (strip) {483 var s = strip.spr;484 var count = strip.count;485 count--;486 if (count < 0) {487 strip.count = -1;488 s.setHeading(strip.finalAngle);489 Prims.showTime(strip);490 strip.thisblock = strip.thisblock.next;491 } else {492 s.setHeading(s.angle + strip.angleStep);493 strip.waitTimer = tinterval;494 strip.count = count;495 }496 }497 static Same (strip) {498 var s = strip.spr;499 var n = (s.defaultScale - s.scale) / s.defaultScale * 10;500 if (n == 0) {501 strip.waitTimer = tinterval;502 strip.thisblock = strip.thisblock.next;503 strip.count = -1;504 strip.distance = -1;505 if (!strip.firstBlock.aStart) {506 s.homescale = s.defaultScale;507 }508 return;509 }510 if (strip.count < 0) {511 strip.distance = s.defaultScale * Math.abs(n) / n * s.speed;512 strip.count = Math.floor(5 * Math.floor(Math.abs(n)) / s.speed);513 Prims.setTime(strip);514 if (!strip.firstBlock.aStart) {515 s.homescale = s.defaultScale;516 }517 }518 if (strip.count == 0) {519 strip.count = -1;520 s.noScaleFor();521 strip.distance = -1;522 Prims.showTime(strip);523 strip.thisblock = strip.thisblock.next;524 } else {525 s.changeSizeBy(strip.distance * 2);526 strip.waitTimer = tinterval;527 strip.count = strip.count - 1;528 }529 }530 static Grow (strip) {531 var s = strip.spr;532 var n = Number(strip.thisblock.getArgValue());533 if (strip.count < 0) {534 strip.distance = Number(s.scale) + (10 * n * s.defaultScale) / 100;535 strip.distance = Math.round(strip.distance * 1000) / 1000;536 strip.count = Math.floor(5 * Math.abs(n) / s.speed);537 Prims.setTime(strip);538 }539 if (strip.count == 0) {540 strip.count = -1;541 s.setScaleTo(strip.distance);542 if (!strip.firstBlock.aStart) {543 s.homescale = s.scale;544 }545 strip.distance = -1;546 Prims.showTime(strip);547 strip.thisblock = strip.thisblock.next;548 } else {549 s.changeSizeBy(s.defaultScale * 2 * s.speed * Math.abs(n) / n);550 strip.waitTimer = tinterval;551 strip.count = strip.count - 1;552 }553 }554 static Shrink (strip) {555 var s = strip.spr;556 var n = Number(strip.thisblock.getArgValue());557 if (strip.count < 0) {558 strip.distance = s.scale - (10 * n * s.defaultScale) / 100;559 strip.distance = Math.round(strip.distance * 1000) / 1000;560 strip.count = Math.floor(5 * Math.abs(n) / s.speed);561 Prims.setTime(strip);562 }563 if (strip.count == 0) {564 strip.count = -1;565 s.setScaleTo(strip.distance);566 if (!strip.firstBlock.aStart) {567 s.homescale = s.scale;568 }569 strip.distance = -1;570 Prims.showTime(strip);571 strip.thisblock = strip.thisblock.next;572 } else {573 s.changeSizeBy(-s.defaultScale * 2 * s.speed * Math.abs(n) / n);574 strip.waitTimer = tinterval;575 strip.count = strip.count - 1;576 }577 }578 static Show (strip) {579 var s = strip.spr;580 s.shown = true;581 if (strip.count < 0) {582 strip.count = s.speed == 4 ? 0 : Math.floor(15 / s.speed);583 Prims.setTime(strip);584 }585 if (strip.count == 0) {586 strip.count = -1;587 s.div.style.opacity = 1;588 Prims.showTime(strip);589 strip.thisblock = strip.thisblock.next;590 if (!strip.firstBlock.aStart) {591 s.homeshown = true;592 }593 } else {594 s.div.style.opacity = Math.min(1, Number(s.div.style.opacity) + (s.speed / 15));595 strip.waitTimer = tinterval * 2;596 strip.count = strip.count - 1;597 }598 }599 static Hide (strip) { // same600 var s = strip.spr;601 s.shown = false;602 if (strip.count < 0) {603 strip.count = s.speed == 4 ? 0 : Math.floor(15 / s.speed);604 Prims.setTime(strip);605 }606 if (strip.count == 0) {607 strip.count = -1;608 s.div.style.opacity = 0;609 Prims.showTime(strip);610 strip.thisblock = strip.thisblock.next;611 if (!strip.firstBlock.aStart) {612 s.homeshown = false;613 }614 } else {615 s.div.style.opacity = Math.max(0, Number(s.div.style.opacity) - (s.speed / 15));616 strip.waitTimer = tinterval * 2;617 strip.count = strip.count - 1;618 }619 }620 static OnTouch (strip) {621 var s = strip.spr;622 if (s.touchingAny()) {623 strip.stack.push(strip.firstBlock);624 strip.thisblock = strip.thisblock.next;625 }626 strip.waitTimer = tinterval;627 }628 static Message (strip) {629 var b = strip.thisblock;630 var pair;631 if (strip.firstTime) {632 var receivers = [];633 var msg = b.getArgValue();634 var findReceivers = function (block, s) {635 if ((block.blocktype == 'onmessage') && (block.getArgValue() == msg)) {636 receivers.push([s, block]);637 }638 };639 Prims.applyToAllStrips(['onmessage'], findReceivers);640 var newthreads = [];641 for (var i in receivers) {642 pair = receivers[i];643 newthreads.push(ScratchJr.runtime.restartThread(pair[0], pair[1], true));644 }645 strip.firstTime = false;646 strip.called = newthreads;647 }648 // after first time649 var done = true;650 for (var j = 0; j < strip.called.length; j++) {651 if (strip.called[j].isRunning) {652 done = false;653 }654 }655 if (done) {656 strip.called = null;657 strip.firstTime = true;658 strip.thisblock = strip.thisblock.next;659 strip.waitTimer = tinterval * 2;660 } else {661 ScratchJr.runtime.yield = true;662 }663 }664 static applyToAllStrips (list, fcn) {665 if (!ScratchJr.stage) {666 return;667 }668 var page = ScratchJr.stage.currentPage;669 if (!page) {670 return;671 }672 if (!page.div) {673 return;674 }675 for (var i = 0; i < page.div.childElementCount; i++) {676 var spr = page.div.childNodes[i].owner;677 if (!spr) {678 continue;679 }680 var sc = gn(spr.id + '_scripts');681 if (!sc) {682 continue;683 }684 var topblocks = sc.owner.getBlocksType(list);685 for (var j = 0; j < topblocks.length; j++) {686 fcn(topblocks[j], spr);687 }688 }689 }...

Full Screen

Full Screen

ug-thumbsstrip.js

Source:ug-thumbsstrip.js Github

copy

Full Screen

1/**2 * thumbs class3 * addon to strip gallery4 */5function UGThumbsStrip(){6 var t = this;7 var g_gallery = new UniteGalleryMain(), g_objGallery, g_objects, g_objWrapper; 8 var g_arrItems, g_objStrip, g_objStripInner;9 var g_aviaControl, g_touchThumbsControl, g_functions = new UGFunctions(); 10 var g_isVertical = false, g_thumbs = new UGThumbsGeneral();11 var g_functions = new UGFunctions();12 13 var g_options = {14 strip_vertical_type: false,15 strip_thumbs_align: "left", //left, center, right, top, middle, bottom - the align of the thumbs when they smaller then the strip size.16 strip_space_between_thumbs:6, //space between thumbs17 strip_thumb_touch_sensetivity:15, //from 1-100, 1 - most sensetive, 100 - most unsensetive18 strip_scroll_to_thumb_duration:500, //duration of scrolling to thumb19 strip_scroll_to_thumb_easing:"easeOutCubic", //easing of scrolling to thumb animation20 strip_control_avia:true, //avia control - move the strip according strip moseover position21 strip_control_touch:true, //touch control - move the strip by dragging it22 strip_padding_top: 0, //add some space from the top 23 strip_padding_bottom: 0, //add some space from the bottom24 strip_padding_left: 0, //add some space from left25 strip_padding_right: 0 //add some space from right26 }27 28 var g_temp = {29 isRunOnce:false,30 is_placed:false,31 isNotFixedThumbs: false,32 handle: null33 };34 35 var g_sizes = {36 stripSize:0, //set after position thumbs37 stripActiveSize:0, //strip size without the padding38 stripInnerSize:0, 39 thumbSize:0,40 thumbSecondSize:0 //size of the height and width of the strip41 }42 43 this.events = { //events variables44 STRIP_MOVE:"stripmove",45 INNER_SIZE_CHANGE:"size_change"46 } 47 48 //the defaults for vertical align49 var g_defaultsVertical = {50 strip_thumbs_align: "top",51 thumb_resize_by: "width"52 }53 54 55 /**56 * set the thumbs strip html57 */ 58 this.setHtml = function(objParent){59 60 if(!objParent){61 var objParent = g_objWrapper;62 if(g_options.parent_container != null)63 objParent = g_options.parent_container; 64 }65 66 objParent.append("<div class='ug-thumbs-strip'><div class='ug-thumbs-strip-inner'></div></div>"); 67 g_objStrip = objParent.children(".ug-thumbs-strip");68 69 g_objStripInner = g_objStrip.children(".ug-thumbs-strip-inner"); 70 71 //put the thumbs to inner strip72 g_thumbs.setHtmlThumbs(g_objStripInner);73 74 //hide thumbs on not fixed mode75 if(g_temp.isNotFixedThumbs == true)76 g_thumbs.hideThumbs();77 78 }79 80 function ___________GENERAL___________(){};81 82 83 /**84 * init the strip85 */86 function initStrip(gallery, customOptions){87 88 g_objects = gallery.getObjects();89 g_gallery = gallery;90 91 g_gallery.attachThumbsPanel("strip", t);92 93 g_objGallery = jQuery(gallery);94 g_objWrapper = g_objects.g_objWrapper;95 g_arrItems = g_objects.g_arrItems;96 g_options = jQuery.extend(g_options, customOptions);97 g_isVertical = g_options.strip_vertical_type;98 99 //set vertical defaults100 if(g_isVertical == true){101 g_options = jQuery.extend(g_options, g_defaultsVertical);102 g_options = jQuery.extend(g_options, customOptions);103 104 customOptions.thumb_resize_by = "width";105 }106 107 g_thumbs.init(gallery, customOptions);108 109 onAfterSetOptions();110 }111 112 113 /**114 * run this funcion after set options.115 */116 function onAfterSetOptions(){117 var thumbsOptions = g_thumbs.getOptions();118 119 g_temp.isNotFixedThumbs = (thumbsOptions.thumb_fixed_size === false);120 g_isVertical = g_options.strip_vertical_type;121 }122 123 124 /**125 * run the strip126 */127 function runStrip(){128 129 g_thumbs.setHtmlProperties();130 131 initSizeParams();132 fixSize();133 positionThumbs();134 135 //run only once136 if(g_temp.isRunOnce == false){137 //init thumbs strip touch138 if(g_options.strip_control_touch == true){139 g_touchThumbsControl = new UGTouchThumbsControl();140 g_touchThumbsControl.init(t);141 }142 //init thumbs strip avia control143 if(g_options.strip_control_avia == true){144 g_aviaControl = new UGAviaControl();145 g_aviaControl.init(t);146 }147 checkControlsEnableDisable();148 g_thumbs.loadThumbsImages();149 150 initEvents();151 }152 153 154 g_temp.isRunOnce = true;155 }156 157 158 /**159 * store strip size and strip active size in vars160 * do after all strip size change161 */162 function storeStripSize(size){163 164 g_sizes.stripSize = size;165 if(g_isVertical == false)166 g_sizes.stripActiveSize = g_sizes.stripSize - g_options.strip_padding_left - g_options.strip_padding_right;167 else168 g_sizes.stripActiveSize = g_sizes.stripSize - g_options.strip_padding_top - g_options.strip_padding_bottom;169 170 if(g_sizes.stripActiveSize < 0)171 g_sizes.stripActiveSize = 0;172 }173 174 175 /**176 * init some size parameters, before size init and after position thumbs177 */178 function initSizeParams(){179 180 //set thumb outer size:181 var arrThumbs = g_objStripInner.children(".ug-thumb-wrapper");182 var firstThumb = jQuery(arrThumbs[0]);183 var thumbsRealWidth = firstThumb.outerWidth();184 var thumbsRealHeight = firstThumb.outerHeight();185 var thumbs_options = g_thumbs.getOptions();186 187 if(g_isVertical == false){ //horizontal188 189 g_sizes.thumbSize = thumbsRealWidth;190 191 if(thumbs_options.thumb_fixed_size == true){192 g_sizes.thumbSecondSize = thumbsRealHeight;193 } else {194 g_sizes.thumbSecondSize = thumbs_options.thumb_height;195 }196 197 storeStripSize(g_objStrip.width());198 g_sizes.stripInnerSize = g_objStripInner.width();199 200 }else{ //vertical201 g_sizes.thumbSize = thumbsRealHeight;202 203 if(thumbs_options.thumb_fixed_size == true){204 g_sizes.thumbSecondSize = thumbsRealWidth;205 } else {206 g_sizes.thumbSecondSize = thumbs_options.thumb_width;207 }208 209 storeStripSize(g_objStrip.height());210 g_sizes.stripInnerSize = g_objStripInner.height(); 211 }212 213 }214 215 216 217 /**218 * set size of inner strip according the orientation219 */220 function setInnerStripSize(innerSize){221 if(g_isVertical == false)222 g_objStripInner.width(innerSize);223 else224 g_objStripInner.height(innerSize);225 226 g_sizes.stripInnerSize = innerSize;227 228 checkControlsEnableDisable();229 230 jQuery(t).trigger(t.events.INNER_SIZE_CHANGE);231 }232 233 234 /**235 * position thumbnails in the thumbs panel236 */237 function positionThumbs(){238 239 var arrThumbs = g_objStripInner.children(".ug-thumb-wrapper");240 241 var posx = 0;242 var posy = 0;243 244 if(g_isVertical == false)245 posy = g_options.strip_padding_top;246 247 for (i = 0; i < arrThumbs.length; i++) {248 249 var objThumb = jQuery(arrThumbs[i]);250 251 //skip from placing if not loaded yet on non fixed mode252 if(g_temp.isNotFixedThumbs == true){253 objItem = g_thumbs.getItemByThumb(objThumb);254 if(objItem.isLoaded == false)255 continue;256 257 //the thumb is hidden if not placed258 objThumb.show();259 }260 261 g_functions.placeElement(objThumb, posx, posy);262 263 if(g_isVertical == false)264 posx += objThumb.outerWidth() + g_options.strip_space_between_thumbs;265 else266 posy += objThumb.outerHeight() + g_options.strip_space_between_thumbs;267 }268 269 //set strip size, width or height270 if(g_isVertical == false)271 var innerStripSize = posx - g_options.strip_space_between_thumbs;272 else273 var innerStripSize = posy - g_options.strip_space_between_thumbs;274 275 setInnerStripSize(innerStripSize);276 }277 278 279 /**280 * fix strip and inner size281 */282 function fixSize(){283 284 if(g_isVertical == false){ //fix horizontal285 286 var height = g_sizes.thumbSecondSize;287 288 var objCssStrip = {};289 objCssStrip["height"] = height+"px";290 291 //set inner strip params292 var objCssInner = {};293 objCssInner["height"] = height+"px";294 }else{ //fix vertical295 296 var width = g_sizes.thumbSecondSize;297 298 var objCssStrip = {};299 objCssStrip["width"] = width+"px";300 301 //set inner strip params302 var objCssInner = {};303 objCssInner["width"] = width+"px";304 305 }306 307 g_objStrip.css(objCssStrip);308 g_objStripInner.css(objCssInner); 309 }310 311 312 313 /**314 * scroll by some number315 * .316 */317 function scrollBy(scrollStep){318 319 var innerPos = t.getInnerStripPos();320 var finalPos = innerPos + scrollStep;321 322 finalPos = t.fixInnerStripLimits(finalPos);323 324 t.positionInnerStrip(finalPos, true); 325 }326 327 /**328 * scroll to thumb from min. (left or top) position329 */330 function scrollToThumbMin(objThumb){331 332 var objThumbPos = getThumbPos(objThumb);333 334 var scrollPos = objThumbPos.min * -1;335 scrollPos = t.fixInnerStripLimits(scrollPos);336 t.positionInnerStrip(scrollPos, true);337 }338 339 340 /**341 * scroll to thumb from max. (right or bottom) position342 */343 function scrollToThumbMax(objThumb){344 345 var objThumbPos = getThumbPos(objThumb); 346 347 var scrollPos = objThumbPos.max * -1 + g_sizes.stripSize;348 scrollPos = t.fixInnerStripLimits(scrollPos);349 350 t.positionInnerStrip(scrollPos, true);351 }352 353 /**354 * scroll to some thumbnail355 */356 function scrollToThumb(objThumb){357 358 if(isStripMovingEnabled() == false)359 return(false);360 361 var objBounds = getThumbsInsideBounds();362 363 var objThumbPos = getThumbPos(objThumb);364 365 if(objThumbPos.min < objBounds.minPosThumbs){ 366 367 var prevThumb = objThumb.prev();368 if(prevThumb.length)369 scrollToThumbMin(prevThumb);370 else 371 scrollToThumbMin(objThumb); 372 373 }else if(objThumbPos.max > objBounds.maxPosThumbs){ 374 375 var nextThumb = objThumb.next();376 if(nextThumb.length)377 scrollToThumbMax(nextThumb);378 else379 scrollToThumbMax(objThumb);380 381 }382 383 }384 385 /**386 * scroll to selected thumb387 */388 function scrollToSelectedThumb(){389 390 var selectedItem = g_gallery.getSelectedItem();391 if(selectedItem == null)392 return(true);393 394 var objThumb = selectedItem.objThumbWrapper;395 if(objThumb)396 scrollToThumb(objThumb);397 398 }399 400 401 402 /**403 * check that the inner strip off the limits position, and reposition it if there is a need404 */405 function checkAndRepositionInnerStrip(){406 if(isStripMovingEnabled() == false)407 return(false);408 409 var pos = t.getInnerStripPos();410 411 var posFixed = t.fixInnerStripLimits(pos);412 413 if(pos != posFixed)414 t.positionInnerStrip(posFixed, true);415 }416 417 418 /**419 * enable / disable controls according inner width (move enabled).420 */421 function checkControlsEnableDisable(){422 423 var isMovingEndbled = isStripMovingEnabled();424 425 if(isMovingEndbled == true){426 427 if(g_aviaControl)428 g_aviaControl.enable();429 430 if(g_touchThumbsControl)431 g_touchThumbsControl.enable();432 433 }else{434 435 if(g_aviaControl)436 g_aviaControl.disable();437 438 if(g_touchThumbsControl)439 g_touchThumbsControl.disable();440 441 }442 443 }444 445 /**446 * align inner strip according the options447 */448 function alignInnerStrip(){449 450 if(isStripMovingEnabled())451 return(false);452 453 if(g_isVertical == false)454 g_functions.placeElement(g_objStripInner, g_options.strip_thumbs_align, 0);455 else456 g_functions.placeElement(g_objStripInner, 0, g_options.strip_thumbs_align);457 458 }459 460 461 function ___________EVENTS___________(){};462 463 /**464 * on thumb click event. Select the thumb465 */466 function onThumbClick(objThumb){467 //cancel click event only if passed significant movement468 if(t.isTouchMotionActive()){469 var isSignificantPassed = g_touchThumbsControl.isSignificantPassed();470 if(isSignificantPassed == true)471 return(true);472 }473 //run select item operation474 var objItem = g_thumbs.getItemByThumb(objThumb);475 g_gallery.selectItem(objItem);476 }477 478 479 /**480 * on some thumb placed, run the resize, but with time passed481 */482 function onThumbPlaced(){483 484 clearTimeout(g_temp.handle);485 486 g_temp.handle = setTimeout(function(){487 488 positionThumbs();489 490 },50);491 492 493 }494 495 /**496 * on item change497 */498 function onItemChange(){499 var objItem = g_gallery.getSelectedItem();500 g_thumbs.setThumbSelected(objItem.objThumbWrapper);501 scrollToThumb(objItem.objThumbWrapper);502 }503 504 505 /**506 * init panel events507 */508 function initEvents(){509 510 g_thumbs.initEvents();511 var objThumbs = g_objStrip.find(".ug-thumb-wrapper");512 513 objThumbs.on("click touchend", function(event){514 515 var clickedThumb = jQuery(this);516 onThumbClick(clickedThumb);517 });518 519 //on item change, make the thumb selected520 g_objGallery.on(g_gallery.events.ITEM_CHANGE, onItemChange);521 522 //position thumbs after each load on non fixed mode523 if(g_temp.isNotFixedThumbs){524 525 jQuery(g_thumbs).on(g_thumbs.events.AFTERPLACEIMAGE, onThumbPlaced);526 527 }528 529 }530 531 532 /**533 * destroy the strip panel events534 */535 this.destroy = function(){536 537 var objThumbs = g_objStrip.find(".ug-thumb-wrapper");538 539 objThumbs.off("click");540 objThumbs.off("touchend");541 g_objGallery.off(g_gallery.events.ITEM_CHANGE);542 jQuery(g_thumbs).off(g_thumbs.events.AFTERPLACEIMAGE);543 544 if(g_touchThumbsControl)545 g_touchThumbsControl.destroy();546 547 if(g_aviaControl)548 g_aviaControl.destroy();549 550 g_thumbs.destroy();551 }552 553 554 function ____________GETTERS___________(){};555 556 /**557 * check if the inner width is more then strip width558 */559 function isStripMovingEnabled(){560 561 if(g_sizes.stripInnerSize > g_sizes.stripActiveSize)562 return(true);563 else564 return(false);565 566 }567 568 569 /**570 * get bounds, if the thumb not in them, it need to be scrolled571 * minPosThumbs, maxPosThumbs - the min and max position that the thumbs should be located to be visible572 */573 function getThumbsInsideBounds(){574 var obj = {};575 var innerPos = t.getInnerStripPos();576 577 //the 1 is gap that avoid exact bounds578 obj.minPosThumbs = innerPos * -1 + 1; 579 obj.maxPosThumbs = innerPos * -1 + g_sizes.stripSize - 1; 580 581 return(obj);582 }583 584 585 /**586 * get thumb position according the orientation in the inner strip587 */588 function getThumbPos(objThumb){589 590 var objReturn = {};591 592 var objPos = objThumb.position();593 594 if(g_isVertical == false){595 objReturn.min = objPos.left;596 objReturn.max = objPos.left + g_sizes.thumbSize;597 }else{598 objReturn.min = objPos.top;599 objReturn.max = objPos.top + g_sizes.thumbSize;600 }601 602 return(objReturn);603 }604 605 606 607 608 this.________EXTERNAL_GENERAL___________ = function(){};609 /**610 * init function for avia controls611 */612 this.init = function(gallery, customOptions){613 614 initStrip(gallery, customOptions);615 }616 617 618 /**619 * set html and properties620 */ 621 this.run = function(){622 runStrip();623 }624 625 626 627 628 /**629 * position inner strip on some pos according the orientation630 */631 this.positionInnerStrip = function(pos, isAnimate){632 633 if(isAnimate === undefined)634 var isAnimate = false;635 636 if(g_isVertical == false)637 var objPosition = {"left": pos + "px"};638 else639 var objPosition = {"top": pos + "px"};640 641 if(isAnimate == false){ //normal position642 643 g_objStripInner.css(objPosition);644 t.triggerStripMoveEvent();645 }646 else{ //position with animation647 648 t.triggerStripMoveEvent();649 650 g_objStripInner.stop(true).animate(objPosition ,{651 duration: g_options.strip_scroll_to_thumb_duration,652 easing: g_options.strip_scroll_to_thumb_easing,653 queue: false,654 progress:function(){t.triggerStripMoveEvent()},655 always: function(){t.triggerStripMoveEvent()}656 }); 657 658 }659 660 }661 /**662 * trigger event - on strip move663 */664 this.triggerStripMoveEvent = function(){665 666 //trigger onstripmove event667 jQuery(t).trigger(t.events.STRIP_MOVE);668 669 }670 671 672 673 /**674 * return true if the touch animation or dragging is active675 */676 this.isTouchMotionActive = function(){677 if(!g_touchThumbsControl)678 return(false);679 680 var isActive = g_touchThumbsControl.isTouchActive();681 682 return(isActive);683 }684 685 686 /**687 * check if thmb item visible, means inside the visible part of the inner strip688 */689 this.isItemThumbVisible = function(objItem){690 691 var objThumb = objItem.objThumbWrapper;692 var thumbPos = objThumb.position();693 694 var posMin = t.getInnerStripPos() * -1;695 696 if(g_isVertical == false){697 var posMax = posMin + g_sizes.stripSize;698 var thumbPosMin = thumbPos.left;699 var thumbPosMax = thumbPos.left + objThumb.width(); 700 }else{701 var posMax = posMin + g_sizes.stripSize;702 var thumbPosMin = thumbPos.top;703 var thumbPosMax = thumbPos.top + objThumb.height(); 704 }705 706 var isVisible = false;707 if(thumbPosMax >= posMin && thumbPosMin <= posMax)708 isVisible = true;709 710 return(isVisible);711 }712 713 /**714 * get inner strip position according the orientation715 */716 this.getInnerStripPos = function(){717 718 if(g_isVertical == false) 719 return g_objStripInner.position().left;720 else721 return g_objStripInner.position().top;722 }723 724 725 /**726 * get inner strip limits727 */728 this.getInnerStripLimits = function(){729 730 var output = {};731 732 if(g_isVertical == false)733 output.maxPos = g_options.strip_padding_left;734 else735 output.maxPos = g_options.strip_padding_top;736 737 //debugLine(g_sizes.stripActiveSize);738 739 output.minPos = -(g_sizes.stripInnerSize - g_sizes.stripActiveSize);740 741 return(output);742 }743 744 /**745 * fix inner position by check boundaries limit746 */747 this.fixInnerStripLimits = function(distPos){748 749 var minPos;750 751 var objLimits = t.getInnerStripLimits();752 753 if(distPos > objLimits.maxPos)754 distPos = objLimits.maxPos;755 756 if(distPos < objLimits.minPos)757 distPos = objLimits.minPos;758 759 return(distPos);760 }761 762 763 764 /**765 * scroll left or down766 */767 this.scrollForeward = function(){768 scrollBy(-g_sizes.stripSize);769 }770 771 772 /**773 * scroll left or down774 */775 this.scrollBack = function(){776 777 scrollBy(g_sizes.stripSize);778 }779 780 781 this.________EXTERNAL_SETTERS___________ = function(){};782 783 /**784 * set the options of the strip785 */786 this.setOptions = function(objOptions){787 788 g_options = jQuery.extend(g_options, objOptions);789 790 g_thumbs.setOptions(objOptions);791 792 onAfterSetOptions();793 }794 795 796 /**797 * set size of the strip798 * the height size is set automatically from options799 */800 this.setSizeVertical = function(height){801 802 if(g_isVertical == false){803 throw new Error("setSizeVertical error, the strip size is not vertical");804 return(false);805 }806 807 var width = g_sizes.thumbSecondSize;808 809 var objCssStrip = {};810 objCssStrip["width"] = width+"px";811 objCssStrip["height"] = height+"px";812 813 g_objStrip.css(objCssStrip);814 storeStripSize(height);815 816 //set inner strip params817 var objCssInner = {};818 objCssInner["width"] = width+"px";819 objCssInner["left"] = "0px";820 objCssInner["top"] = "0px";821 822 g_objStripInner.css(objCssInner);823 824 g_temp.is_placed = true;825 826 checkControlsEnableDisable();827 }828 829 /**830 * set size of the strip831 * the height size is set automatically from options832 */833 this.setSizeHorizontal = function(width){834 835 if(g_isVertical == true){836 throw new Error("setSizeHorizontal error, the strip size is not horizontal");837 return(false);838 }839 840 var height = g_sizes.thumbSecondSize + g_options.strip_padding_top + g_options.strip_padding_bottom;841 842 var objCssStrip = {};843 objCssStrip["width"] = width+"px";844 objCssStrip["height"] = height+"px";845 846 g_objStrip.css(objCssStrip);847 848 storeStripSize(width);849 850 var innerLeft = g_options.strip_padding_left;851 852 //set inner strip params853 var objCssInner = {};854 objCssInner["height"] = height+"px";855 objCssInner["left"] = innerLeft + "px";856 objCssInner["top"] = "0px";857 858 g_objStripInner.css(objCssInner);859 860 g_temp.is_placed = true;861 862 checkControlsEnableDisable();863 }864 865 866 /**867 * set position of the strip868 */869 this.setPosition = function(left, top, offsetLeft, offsetTop){870 g_functions.placeElement(g_objStrip, left, top, offsetLeft, offsetTop); 871 }872 873 874 /**875 * resize the panel according the orientation876 */877 this.resize = function(newSize){878 879 if(g_isVertical == false){880 881 g_objStrip.width(newSize);882 g_sizes.stripActiveSize = newSize - g_options.strip_padding_left - g_options.strip_padding_right;883 }else{884 g_objStrip.height(newSize);885 g_sizes.stripActiveSize = newSize - g_options.strip_padding_top - g_options.strip_padding_bottom;886 }887 888 storeStripSize(newSize);889 890 checkControlsEnableDisable();891 892 checkAndRepositionInnerStrip();893 894 alignInnerStrip();895 896 scrollToSelectedThumb();897 }898 899 900 /**901 * set the thumb unselected state902 */903 this.setThumbUnselected = function(objThumbWrapper){904 905 g_thumbs.setThumbUnselected(objThumbWrapper);906 907 }908 909 910 /**911 * set custom thumbs912 */913 this.setCustomThumbs = function(funcSetHtml){914 915 g_thumbs.setCustomThumbs(funcSetHtml);916 917 }918 919 920 921 922 this.________EXTERNAL_GETTERS___________ = function(){};923 924 /**925 * get objects926 */ 927 this.getObjects = function(){928 929 var thumbsOptions = g_thumbs.getOptions();930 var commonOpitions = jQuery.extend(g_options, thumbsOptions);931 932 var obj = {933 g_gallery: g_gallery,934 g_objGallery: g_objGallery,935 g_objWrapper:g_objWrapper,936 g_arrItems:g_arrItems,937 g_objStrip : g_objStrip,938 g_objStripInner : g_objStripInner,939 g_aviaControl:g_aviaControl,940 g_touchThumbsControl:g_touchThumbsControl,941 isVertical: g_isVertical,942 g_options: commonOpitions,943 g_thumbs: g_thumbs944 };945 946 return(obj);947 }948 949 950 /**951 * get thumbs onject952 */953 this.getObjThumbs = function(){954 955 return(g_thumbs);956 }957 958 959 /**960 * get selected thumb961 */962 this.getSelectedThumb = function(){963 964 var selectedIndex = g_gallery.getSelectedItemIndex();965 if(selectedIndex == -1)966 return(null);967 968 return g_thumbs.getThumbByIndex(selectedIndex);969 }970 971 972 /**973 * get strip size and position object974 */975 this.getSizeAndPosition = function(){976 977 var obj = g_functions.getElementSize(g_objStrip);978 979 return(obj);980 }981 982 /**983 * get thumbs strip height984 */985 this.getHeight = function(){986 987 var stripHeight = g_objStrip.outerHeight();988 989 return(stripHeight)990 }991 992 993 /**994 * get thumbs strip width995 */996 this.getWidth = function(){997 998 var stripWidth = g_objStrip.outerWidth();999 1000 return(stripWidth);1001 }1002 1003 1004 1005 /**1006 * get all stored sizes object1007 */1008 this.getSizes = function(){1009 1010 return(g_sizes);1011 }1012 1013 1014 /**1015 * return if vertical orientation or not1016 */1017 this.isVertical = function(){1018 return(g_isVertical);1019 }1020 1021 1022 /**1023 * return if the strip is placed or not1024 */1025 this.isPlaced = function(){1026 1027 return(g_temp.is_placed);1028 }1029 1030 /**1031 * return if the strip moving enabled or not1032 */1033 this.isMoveEnabled = function(){1034 var isEnabled = isStripMovingEnabled();1035 return(isEnabled);1036 }...

Full Screen

Full Screen

inbuilt_function_tostring.js

Source:inbuilt_function_tostring.js Github

copy

Full Screen

1 function StripSpaces( s ) {2 for ( var currentChar = 0, strippedString="";3 currentChar < s.length; currentChar++ )4 {5 if (!IsWhiteSpace(s.charAt(currentChar))) {6 strippedString += s.charAt(currentChar);7 }8 }9 return strippedString;10 }11 function IsWhiteSpace( string ) {12 var cc = string.charCodeAt(0);13 switch (cc) {14 case (0x0009):15 case (0x000B):16 case (0x000C):17 case (0x0020):18 case (0x000A):19 case (0x000D):20 case ( 59 ): // let's strip out semicolons, too21 return true;22 break;23 default:24 return false;25 }26 }27shouldBe("StripSpaces(eval.toString())","\"functioneval(){[nativecode]}\"");28shouldBe("StripSpaces(parseInt.toString())","\"functionparseInt(){[nativecode]}\"");29shouldBe("StripSpaces(parseFloat.toString())","\"functionparseFloat(){[nativecode]}\"");30shouldBe("StripSpaces(isNaN.toString())","\"functionisNaN(){[nativecode]}\"");31shouldBe("StripSpaces(isFinite.toString())","\"functionisFinite(){[nativecode]}\"");32shouldBe("StripSpaces(escape.toString())","\"functionescape(){[nativecode]}\"");33shouldBe("StripSpaces(unescape.toString())","\"functionunescape(){[nativecode]}\"");34shouldBe("StripSpaces(Object.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");35shouldBe("StripSpaces(Object.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");36shouldBe("StripSpaces(Object.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");37shouldBe("StripSpaces(Object.prototype.hasOwnProperty.toString())","\"functionhasOwnProperty(){[nativecode]}\"");38shouldBe("StripSpaces(Object.prototype.isPrototypeOf.toString())","\"functionisPrototypeOf(){[nativecode]}\"");39shouldBe("StripSpaces(Object.prototype.propertyIsEnumerable.toString())","\"functionpropertyIsEnumerable(){[nativecode]}\"");40shouldBe("StripSpaces(Function.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");41shouldBe("StripSpaces(Function.prototype.apply.toString())","\"functionapply(){[nativecode]}\"");42shouldBe("StripSpaces(Function.prototype.call.toString())","\"functioncall(){[nativecode]}\"");43shouldBe("StripSpaces(Array.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");44shouldBe("StripSpaces(Array.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");45shouldBe("StripSpaces(Array.prototype.concat.toString())","\"functionconcat(){[nativecode]}\"");46shouldBe("StripSpaces(Array.prototype.join.toString())","\"functionjoin(){[nativecode]}\"");47shouldBe("StripSpaces(Array.prototype.pop.toString())","\"functionpop(){[nativecode]}\"");48shouldBe("StripSpaces(Array.prototype.push.toString())","\"functionpush(){[nativecode]}\"");49shouldBe("StripSpaces(Array.prototype.reverse.toString())","\"functionreverse(){[nativecode]}\"");50shouldBe("StripSpaces(Array.prototype.shift.toString())","\"functionshift(){[nativecode]}\"");51shouldBe("StripSpaces(Array.prototype.slice.toString())","\"functionslice(){[nativecode]}\"");52shouldBe("StripSpaces(Array.prototype.sort.toString())","\"functionsort(){[nativecode]}\"");53shouldBe("StripSpaces(Array.prototype.splice.toString())","\"functionsplice(){[nativecode]}\"");54shouldBe("StripSpaces(Array.prototype.unshift.toString())","\"functionunshift(){[nativecode]}\"");55shouldBe("StripSpaces(String.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");56shouldBe("StripSpaces(String.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");57shouldBe("StripSpaces(String.prototype.charAt.toString())","\"functioncharAt(){[nativecode]}\"");58shouldBe("StripSpaces(String.prototype.charCodeAt.toString())","\"functioncharCodeAt(){[nativecode]}\"");59shouldBe("StripSpaces(String.prototype.concat.toString())","\"functionconcat(){[nativecode]}\"");60shouldBe("StripSpaces(String.prototype.indexOf.toString())","\"functionindexOf(){[nativecode]}\"");61shouldBe("StripSpaces(String.prototype.lastIndexOf.toString())","\"functionlastIndexOf(){[nativecode]}\"");62shouldBe("StripSpaces(String.prototype.match.toString())","\"functionmatch(){[nativecode]}\"");63shouldBe("StripSpaces(String.prototype.replace.toString())","\"functionreplace(){[nativecode]}\"");64shouldBe("StripSpaces(String.prototype.search.toString())","\"functionsearch(){[nativecode]}\"");65shouldBe("StripSpaces(String.prototype.slice.toString())","\"functionslice(){[nativecode]}\"");66shouldBe("StripSpaces(String.prototype.split.toString())","\"functionsplit(){[nativecode]}\"");67shouldBe("StripSpaces(String.prototype.substr.toString())","\"functionsubstr(){[nativecode]}\"");68shouldBe("StripSpaces(String.prototype.substring.toString())","\"functionsubstring(){[nativecode]}\"");69shouldBe("StripSpaces(String.prototype.toLowerCase.toString())","\"functiontoLowerCase(){[nativecode]}\"");70shouldBe("StripSpaces(String.prototype.toUpperCase.toString())","\"functiontoUpperCase(){[nativecode]}\"");71shouldBe("StripSpaces(String.prototype.big.toString())","\"functionbig(){[nativecode]}\"");72shouldBe("StripSpaces(String.prototype.small.toString())","\"functionsmall(){[nativecode]}\"");73shouldBe("StripSpaces(String.prototype.blink.toString())","\"functionblink(){[nativecode]}\"");74shouldBe("StripSpaces(String.prototype.bold.toString())","\"functionbold(){[nativecode]}\"");75shouldBe("StripSpaces(String.prototype.fixed.toString())","\"functionfixed(){[nativecode]}\"");76shouldBe("StripSpaces(String.prototype.italics.toString())","\"functionitalics(){[nativecode]}\"");77shouldBe("StripSpaces(String.prototype.strike.toString())","\"functionstrike(){[nativecode]}\"");78shouldBe("StripSpaces(String.prototype.sub.toString())","\"functionsub(){[nativecode]}\"");79shouldBe("StripSpaces(String.prototype.sup.toString())","\"functionsup(){[nativecode]}\"");80shouldBe("StripSpaces(String.prototype.fontcolor.toString())","\"functionfontcolor(){[nativecode]}\"");81shouldBe("StripSpaces(String.prototype.fontsize.toString())","\"functionfontsize(){[nativecode]}\"");82shouldBe("StripSpaces(String.prototype.anchor.toString())","\"functionanchor(){[nativecode]}\"");83shouldBe("StripSpaces(String.prototype.link.toString())","\"functionlink(){[nativecode]}\"");84shouldBe("StripSpaces(Boolean.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");85shouldBe("StripSpaces(Boolean.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");86shouldBe("StripSpaces(Number.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");87shouldBe("StripSpaces(Number.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");88shouldBe("StripSpaces(Number.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");89shouldBe("StripSpaces(Number.prototype.toFixed.toString())","\"functiontoFixed(){[nativecode]}\"");90shouldBe("StripSpaces(Number.prototype.toExponential.toString())","\"functiontoExponential(){[nativecode]}\"");91shouldBe("StripSpaces(Number.prototype.toPrecision.toString())","\"functiontoPrecision(){[nativecode]}\"");92shouldBe("StripSpaces(Math.abs.toString())","\"functionabs(){[nativecode]}\"");93shouldBe("StripSpaces(Math.acos.toString())","\"functionacos(){[nativecode]}\"");94shouldBe("StripSpaces(Math.asin.toString())","\"functionasin(){[nativecode]}\"");95shouldBe("StripSpaces(Math.atan.toString())","\"functionatan(){[nativecode]}\"");96shouldBe("StripSpaces(Math.atan2.toString())","\"functionatan2(){[nativecode]}\"");97shouldBe("StripSpaces(Math.ceil.toString())","\"functionceil(){[nativecode]}\"");98shouldBe("StripSpaces(Math.cos.toString())","\"functioncos(){[nativecode]}\"");99shouldBe("StripSpaces(Math.exp.toString())","\"functionexp(){[nativecode]}\"");100shouldBe("StripSpaces(Math.floor.toString())","\"functionfloor(){[nativecode]}\"");101shouldBe("StripSpaces(Math.log.toString())","\"functionlog(){[nativecode]}\"");102shouldBe("StripSpaces(Math.max.toString())","\"functionmax(){[nativecode]}\"");103shouldBe("StripSpaces(Math.min.toString())","\"functionmin(){[nativecode]}\"");104shouldBe("StripSpaces(Math.pow.toString())","\"functionpow(){[nativecode]}\"");105shouldBe("StripSpaces(Math.random.toString())","\"functionrandom(){[nativecode]}\"");106shouldBe("StripSpaces(Math.round.toString())","\"functionround(){[nativecode]}\"");107shouldBe("StripSpaces(Math.sin.toString())","\"functionsin(){[nativecode]}\"");108shouldBe("StripSpaces(Math.sqrt.toString())","\"functionsqrt(){[nativecode]}\"");109shouldBe("StripSpaces(Math.tan.toString())","\"functiontan(){[nativecode]}\"");110shouldBe("StripSpaces(Date.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");111shouldBe("StripSpaces(Date.prototype.toUTCString.toString())","\"functiontoUTCString(){[nativecode]}\"");112shouldBe("StripSpaces(Date.prototype.toDateString.toString())","\"functiontoDateString(){[nativecode]}\"");113shouldBe("StripSpaces(Date.prototype.toTimeString.toString())","\"functiontoTimeString(){[nativecode]}\"");114shouldBe("StripSpaces(Date.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");115shouldBe("StripSpaces(Date.prototype.toLocaleDateString.toString())","\"functiontoLocaleDateString(){[nativecode]}\"");116shouldBe("StripSpaces(Date.prototype.toLocaleTimeString.toString())","\"functiontoLocaleTimeString(){[nativecode]}\"");117shouldBe("StripSpaces(Date.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");118shouldBe("StripSpaces(Date.prototype.getTime.toString())","\"functiongetTime(){[nativecode]}\"");119shouldBe("StripSpaces(Date.prototype.getFullYear.toString())","\"functiongetFullYear(){[nativecode]}\"");120shouldBe("StripSpaces(Date.prototype.getUTCFullYear.toString())","\"functiongetUTCFullYear(){[nativecode]}\"");121shouldBe("StripSpaces(Date.prototype.toGMTString.toString())","\"functiontoGMTString(){[nativecode]}\"");122shouldBe("StripSpaces(Date.prototype.getMonth.toString())","\"functiongetMonth(){[nativecode]}\"");123shouldBe("StripSpaces(Date.prototype.getUTCMonth.toString())","\"functiongetUTCMonth(){[nativecode]}\"");124shouldBe("StripSpaces(Date.prototype.getDate.toString())","\"functiongetDate(){[nativecode]}\"");125shouldBe("StripSpaces(Date.prototype.getUTCDate.toString())","\"functiongetUTCDate(){[nativecode]}\"");126shouldBe("StripSpaces(Date.prototype.getDay.toString())","\"functiongetDay(){[nativecode]}\"");127shouldBe("StripSpaces(Date.prototype.getUTCDay.toString())","\"functiongetUTCDay(){[nativecode]}\"");128shouldBe("StripSpaces(Date.prototype.getHours.toString())","\"functiongetHours(){[nativecode]}\"");129shouldBe("StripSpaces(Date.prototype.getUTCHours.toString())","\"functiongetUTCHours(){[nativecode]}\"");130shouldBe("StripSpaces(Date.prototype.getMinutes.toString())","\"functiongetMinutes(){[nativecode]}\"");131shouldBe("StripSpaces(Date.prototype.getUTCMinutes.toString())","\"functiongetUTCMinutes(){[nativecode]}\"");132shouldBe("StripSpaces(Date.prototype.getSeconds.toString())","\"functiongetSeconds(){[nativecode]}\"");133shouldBe("StripSpaces(Date.prototype.getUTCSeconds.toString())","\"functiongetUTCSeconds(){[nativecode]}\"");134shouldBe("StripSpaces(Date.prototype.getMilliseconds.toString())","\"functiongetMilliseconds(){[nativecode]}\"");135shouldBe("StripSpaces(Date.prototype.getUTCMilliseconds.toString())","\"functiongetUTCMilliseconds(){[nativecode]}\"");136shouldBe("StripSpaces(Date.prototype.getTimezoneOffset.toString())","\"functiongetTimezoneOffset(){[nativecode]}\"");137shouldBe("StripSpaces(Date.prototype.setTime.toString())","\"functionsetTime(){[nativecode]}\"");138shouldBe("StripSpaces(Date.prototype.setMilliseconds.toString())","\"functionsetMilliseconds(){[nativecode]}\"");139shouldBe("StripSpaces(Date.prototype.setUTCMilliseconds.toString())","\"functionsetUTCMilliseconds(){[nativecode]}\"");140shouldBe("StripSpaces(Date.prototype.setSeconds.toString())","\"functionsetSeconds(){[nativecode]}\"");141shouldBe("StripSpaces(Date.prototype.setUTCSeconds.toString())","\"functionsetUTCSeconds(){[nativecode]}\"");142shouldBe("StripSpaces(Date.prototype.setMinutes.toString())","\"functionsetMinutes(){[nativecode]}\"");143shouldBe("StripSpaces(Date.prototype.setUTCMinutes.toString())","\"functionsetUTCMinutes(){[nativecode]}\"");144shouldBe("StripSpaces(Date.prototype.setHours.toString())","\"functionsetHours(){[nativecode]}\"");145shouldBe("StripSpaces(Date.prototype.setUTCHours.toString())","\"functionsetUTCHours(){[nativecode]}\"");146shouldBe("StripSpaces(Date.prototype.setDate.toString())","\"functionsetDate(){[nativecode]}\"");147shouldBe("StripSpaces(Date.prototype.setUTCDate.toString())","\"functionsetUTCDate(){[nativecode]}\"");148shouldBe("StripSpaces(Date.prototype.setMonth.toString())","\"functionsetMonth(){[nativecode]}\"");149shouldBe("StripSpaces(Date.prototype.setUTCMonth.toString())","\"functionsetUTCMonth(){[nativecode]}\"");150shouldBe("StripSpaces(Date.prototype.setFullYear.toString())","\"functionsetFullYear(){[nativecode]}\"");151shouldBe("StripSpaces(Date.prototype.setUTCFullYear.toString())","\"functionsetUTCFullYear(){[nativecode]}\"");152shouldBe("StripSpaces(Date.prototype.setYear.toString())","\"functionsetYear(){[nativecode]}\"");153shouldBe("StripSpaces(Date.prototype.getYear.toString())","\"functiongetYear(){[nativecode]}\"");154shouldBe("StripSpaces(Date.prototype.toGMTString.toString())","\"functiontoGMTString(){[nativecode]}\"");155shouldBe("StripSpaces(RegExp.prototype.exec.toString())","\"functionexec(){[nativecode]}\"");156shouldBe("StripSpaces(RegExp.prototype.test.toString())","\"functiontest(){[nativecode]}\"");157shouldBe("StripSpaces(RegExp.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");158shouldBe("StripSpaces(Error.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");...

Full Screen

Full Screen

jquery.webticker.js

Source:jquery.webticker.js Github

copy

Full Screen

1/*!2 * webTicker 2.1.13 * Examples and documentation at:4 * http://jonmifsud.com/open-source/jquery/jquery-webticker/5 * 2011 Jonathan Mifsud6 * Version: 2.1.1 (23-MAY-2013)7 * Dual licensed under the Creative Commons and DonationWare licenses:8 * http://creativecommons.org/licenses/by-nc/3.0/9 * https://github.com/jonmifsud/Web-Ticker/blob/master/licence.md10 * Requires:11 * jQuery v1.4.2 or later12 *13 */14(function( $ ){15 var cssTransitionsSupported = (function() {16 var s = document.createElement('p').style,17 v = ['ms','O','Moz','Webkit'];18 if( s['transition'] == '' ) return true;19 while( v.length )20 if( v.pop() + 'Transition' in s )21 return true;22 return false;23 })();24 function scrollitems($strip,moveFirst){25 var settings = $strip.data('settings') || { direction: "left" };26 if (typeof moveFirst === 'undefined')27 moveFirst = false;28 if (moveFirst){29 moveFirstElement($strip);30 }31 var options = animationSettings($strip);32 $strip.animate(options.css, options.time, "linear", function(){33 $strip.css(settings.direction, '0');34 scrollitems($strip,true);35 });36 }37 function animationSettings($strip){38 var settings = $strip.data('settings') || { direction: "left", speed: 50 };39 var first = $strip.children().first();40 var distance = Math.abs(-$strip.css(settings.direction).replace('px','').replace('auto','0') - first.outerWidth(true));41 var settings = $strip.data('settings');42 var timeToComplete = distance * 1000 / settings.speed;43 var animationSettings = {};44 animationSettings[settings.direction] = $strip.css(settings.direction).replace('px','').replace('auto','0') - distance;45 return {'css':animationSettings,'time':timeToComplete};46 }47 function moveFirstElement($strip){48 var settings = $strip.data('settings') || { direction: "left" };49 $strip.css('transition-duration','0s').css(settings.direction, '0');50 var $first = $strip.children().first();51 if ($first.hasClass('webticker-init'))52 $first.remove();53 else54 $strip.children().last().after($first);55 }56 function css3Scroll($strip,moveFirst){57 if (typeof moveFirst === 'undefined')58 moveFirst = false;59 if (moveFirst){60 moveFirstElement($strip);61 }62 var options = animationSettings($strip);63 var time = options.time/1000;64 time += 's';65 $strip.css(options.css).css('transition-duration',time);66 }67 function updaterss(rssurl,type,$strip){68 var list = [];69 $.get(rssurl, function(data) {70 var $xml = $(data);71 $xml.find("entry").each(function() {72 var $this = $(this),73 item = {74 title: $this.find("title").text(),75 link: $this.find("link").attr('href')76 }77 listItem = "<li><a href='"+item.link+"'>"+item.title+"</a></li>";78 list += listItem;79 //Do something with item here...80 });81 $strip.webTicker('update', list, type);82 });83 }84 function initalize($strip){85 if ($strip.children('li').length < 1) {86 if (window.console) {87 console.log('no items to initialize');88 }89 return false;90 }91 var settings = $strip.data('settings');92 settings.duplicateLoops = settings.duplicateLoops || 0;93 $strip.width('auto');94 //Find the real width of all li elements95 var stripWidth = 0;96 $strip.children('li').each(function(){97 stripWidth += $(this).outerWidth( true );98 });99 if(stripWidth < $strip.parent().width() || $strip.children().length == 1){100 //if duplicate items101 if (settings.duplicate){102 //Check how many times to duplicate depending on width.103 itemWidth = Math.max.apply(Math, $strip.children().map(function(){ return $(this).width(); }).get());104 var duplicateLoops = 0;105 while (stripWidth - itemWidth < $strip.parent().width() || $strip.children().length == 1 || duplicateLoops < settings.duplicateLoops){106 var listItems = $strip.children().clone();107 $strip.append(listItems);108 stripWidth = 0;109 $strip.children('li').each(function(){110 stripWidth += $(this).outerWidth( true );111 });112 itemWidth = Math.max.apply(Math, $strip.children().map(function(){ return $(this).width(); }).get());113 duplicateLoops++;114 }115 settings.duplicateLoops = duplicateLoops;116 }else {117 //if fill with empty padding118 var emptySpace = $strip.parent().width() - stripWidth;119 emptySpace += $strip.find("li:first").width();120 var height = $strip.find("li:first").height();121 $strip.append('<li class="ticker-spacer" style="width:'+emptySpace+'px;height:'+height+'px;"></li>');122 }123 }124 if (settings.startEmpty){125 var height = $strip.find("li:first").height();126 $strip.prepend('<li class="webticker-init" style="width:'+$strip.parent().width()+'px;height:'+height+'px;"></li>');127 }128 //extra width to be able to move items without any jumps $strip.find("li:first").width()129 stripWidth = 0;130 $strip.children('li').each(function(){131 stripWidth += $(this).outerWidth( true );132 });133 $strip.width(stripWidth+200);134 widthCompare = 0;135 $strip.children('li').each(function(){136 widthCompare += $(this).outerWidth( true );137 });138 //loop to find weather the items inside the list are actually bigger then the size of the whole list. Increments in 200px.139 //only required when a single item is bigger then the whole list140 while (widthCompare >= $strip.width()){141 $strip.width($strip.width()+200);142 widthCompare = 0;143 $strip.children('li').each(function(){144 widthCompare += $(this).outerWidth( true );145 });146 }147 return true;148 }149 var methods = {150 init : function( settings ) { // THIS151 settings = jQuery.extend({152 speed: 50, //pixels per second153 direction: "left",154 moving: true,155 startEmpty: true,156 duplicate: false,157 rssurl: false,158 hoverpause: true,159 rssfrequency: 0,160 updatetype: "reset"161 }, settings);162 //set data-ticker a unique ticker identifier if it does not exist163 return this.each(function(){164 jQuery(this).data('settings',settings);165 var $strip = jQuery(this);166 $strip.addClass("newsticker");167 var $mask = $strip.wrap("<div class='mask'></div>");168 $mask.after("<span class='tickeroverlay-left'>&nbsp;</span><span class='tickeroverlay-right'>&nbsp;</span>")169 var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");170 var started = initalize($strip);171 if (settings.rssurl){172 updaterss(settings.rssurl,settings.type,$strip);173 if (settings.rssfrequency>0){174 window.setInterval(function(){updaterss(settings.rssurl,settings.type,$strip);},settings.rssfrequency*1000*60);175 }176 }177 if (cssTransitionsSupported){178 //fix for firefox not animating default transitions179 $strip.css('transition-duration','0s').css(settings.direction, '0');180 if (started){181 //if list has items and set up start scrolling182 css3Scroll($strip,false);183 }184 //started or not still bind on the transition end event so it works after update185 $strip.on('transitionend webkitTransitionEnd oTransitionEnd otransitionend', function(event) {186 if (!$strip.is(event.target)) {187 return false;188 }189 css3Scroll($(this),true);190 }); 191 } else {192 if (started){193 //if list has items and set up start scrolling194 scrollitems($(this));195 }196 }197 if (settings.hoverpause){198 $strip.hover(function(){199 if (cssTransitionsSupported){200 var currentPosition = $(this).css(settings.direction);201 $(this).css('transition-duration','0s').css(settings.direction,currentPosition);202 } else203 jQuery(this).stop();204 },205 function(){206 if (jQuery(this).data('settings').moving){207 if (cssTransitionsSupported){208 css3Scroll($(this),false);209 // $(this).css("-webkit-animation-play-state", "running");210 } else {211 //usual continue stuff212 scrollitems($strip);213 }214 }215 });216 }217 });218 },219 stop : function( ) {220 var settings = $(this).data('settings');221 if (settings.moving){222 settings.moving = false;223 return this.each(function(){224 if (cssTransitionsSupported){225 var currentPosition = $(this).css(settings.direction);226 $(this).css('transition-duration','0s').css(settings.direction,currentPosition);227 } else228 $(this).stop();229 });230 }231 },232 cont : function( ) {233 var settings = $(this).data('settings')234 if (!settings.moving){235 settings.moving = true;236 return this.each(function(){237 if (cssTransitionsSupported){238 css3Scroll($(this),false);239 } else {240 scrollitems($(this));241 }242 });243 }244 },245 update : function( list, type, insert, remove) {246 type = type || "reset";247 if (typeof insert === 'undefined')248 insert = true;249 if (typeof remove === 'undefined')250 remove = false;251 if( typeof list === 'string' ) {252 list = $(list);253 }254 var $strip = $(this);255 $strip.webTicker('stop');256 var settings = $(this).data('settings');257 if (type == 'reset'){258 //this does a 'restart of the ticker'259 $strip.html(list);260 $strip.css(settings.direction, '0');261 initalize($strip);262 } else if (type == 'swap'){263 if (window.console) {264 console.log('trying to update');265 }266 if ($strip.children('li').length < 1){267 //there were no items treat as if new268 $strip.html(list);269 $strip.css(settings.direction, '0');270 initalize($strip);271 } else {272 // should the update be a 'hot-swap' or use replacement for IDs (in which case remove new ones)273 $strip.children('li').addClass('old');274 for (var i = 0; i < list.length; i++) {275 id = $(list[i]).data('update');276 match = $strip.find('[data-update="'+id+'"]');//should try find the id or data-attribute.277 if (match.length < 1){278 if (insert){279 //we need to move this item into the dom280 if ($strip.find('.ticker-spacer:first-child').length == 0 && $strip.find('.ticker-spacer').length > 0){281 $strip.children('li.ticker-spacer').before(list[i]);282 }283 else {284 $strip.append(list[i]);285 }286 }287 } else $strip.find('[data-update="'+id+'"]').replaceWith(list[i]);;288 };289 $strip.children('li.webticker-init, li.ticker-spacer').removeClass('old');290 if (remove)291 $strip.children('li').remove('.old');292 stripWidth = 0;293 $strip.children('li').each(function(){294 stripWidth += $(this).outerWidth( true );295 });296 $strip.width(stripWidth+200);297 }298 }299 $strip.webTicker('cont');300 }301 };302 $.fn.webTicker = function( method ) {303 // Method calling logic304 if ( methods[method] ) {305 return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));306 } else if ( typeof method === 'object' || ! method ) {307 return methods.init.apply( this, arguments );308 } else {309 $.error( 'Method ' + method + ' does not exist on jQuery.webTicker' );310 }311 };...

Full Screen

Full Screen

ug-avia.js

Source:ug-avia.js Github

copy

Full Screen

1/**2 * avia control class3 * addon to strip gallery4 */5function UGAviaControl(){6 var g_parent, g_gallery, g_objects, g_objStrip, g_objStripInner, g_options;7 var g_isVertical;8 9 var g_temp = {10 touchEnabled:false, //variable that tells if touch event was before move event11 isMouseInsideStrip: false,12 strip_finalPos:0,13 handle_timeout:"",14 isStripMoving:false,15 isControlEnabled: true16 };17 18 19 /**20 * enable the control21 */22 this.enable = function(){23 g_temp.isControlEnabled = true;24 }25 26 /**27 * disable the control28 */29 this.disable = function(){30 g_temp.isControlEnabled = false; 31 }32 33 /**34 * init function for avia controls35 */36 this.init = function(objParent){37 g_parent = objParent;38 39 g_objects = objParent.getObjects();40 41 g_gallery = g_objects.g_gallery;42 43 g_objStrip = g_objects.g_objStrip;44 g_objStripInner = g_objects.g_objStripInner;45 g_options = g_objects.g_options;46 g_isVertical = g_objects.isVertical; 47 48 initEvents();49 }50 51 /**52 * get mouse position from event according the orientation53 */54 function getMousePos(event){55 56 if(g_isVertical == false)57 return(event.pageX);58 59 return(event.pageY);60 }61 62 /**63 * handle avia strip control event on body mouse move64 */65 function initEvents(event){66 67 //make sure that the avia control will not work on touch devices68 jQuery("body").on("touchstart", function(event){69 70 if(g_temp.isControlEnabled == false)71 return(true);72 73 g_temp.touchEnabled = true;74 75 });76 77 //on body move78 jQuery("body").mousemove(function(event){79 80 if(g_temp.isControlEnabled == false)81 return(true);82 83 //protection for touch devices, disable the avia events84 if(g_temp.touchEnabled == true){85 jQuery("body").off("mousemove");86 return(true);87 }88 89 g_temp.isMouseInsideStrip = g_objStrip.ismouseover();90 var strip_touch_active = g_parent.isTouchMotionActive();91 92 if(g_temp.isMouseInsideStrip == true && strip_touch_active == false){93 94 var mousePos = getMousePos(event);95 96 moveStripToMousePosition(mousePos);97 }else{98 stopStripMovingLoop();99 }100 101 });102 103 }104 105 106 /**107 * destroy the avia control events108 */109 this.destroy = function(){110 111 jQuery("body").off("touchstart");112 jQuery("body").off("mousemove");113 }114 115 116 /**117 * get inner y position according mouse y position on the strip118 */119 function getInnerPosY(mouseY){120 var innerOffsetTop = g_options.strip_padding_top;121 var innerOffsetBottom = g_options.strip_padding_bottom;122 var stripHeight = g_objStrip.height();123 var innerHeight = g_objStripInner.height(); 124 125 //if all thumbs visible, no need to move126 if(stripHeight > innerHeight)127 return(null);128 129 //find y position inside the strip130 var stripOffset = g_objStrip.offset(); 131 var offsetY = stripOffset.top;132 var posy = mouseY - offsetY - innerOffsetTop;133 if(posy < 0)134 return(null);135 136 //set measure line parameters137 var mlineStart = g_options.thumb_height;138 var mlineEnd = stripHeight - g_options.thumb_height;139 var mLineSize = mlineEnd - mlineStart;140 141 //fix position borders on the measure line142 if(posy < mlineStart)143 posy = mlineStart;144 145 if(posy > mlineEnd)146 posy = mlineEnd;147 148 //count the ratio of the position on the measure line149 var ratio = (posy - mlineStart) / mLineSize;150 var innerPosY = (innerHeight - stripHeight) * ratio;151 innerPosY = Math.round(innerPosY) * -1 + innerOffsetTop;152 153 return(innerPosY);154 }155 156 /**157 * get inner x position according mouse x position on the strip158 */159 function getInnerPosX(mouseX){160 161 var innerOffsetLeft = g_options.strip_padding_left;162 var innerOffsetRight = g_options.strip_padding_right;163 164 var stripWidth = g_objStrip.width() - innerOffsetLeft - innerOffsetRight;165 var innerWidth = g_objStripInner.width();166 167 //if all thumbs visible, no need to move168 if(stripWidth > innerWidth)169 return(null);170 171 var stripOffset = g_objStrip.offset();172 var offsetX = stripOffset.left;173 var posx = mouseX - offsetX - innerOffsetLeft;174 175 //set measure line parameters176 var mlineStart = g_options.thumb_width;177 var mlineEnd = stripWidth - g_options.thumb_width;178 var mLineSize = mlineEnd - mlineStart;179 180 //fix position borders on the measure line181 if(posx < mlineStart)182 posx = mlineStart;183 184 if(posx > mlineEnd)185 posx = mlineEnd;186 187 //count the ratio of the position on the measure line188 var ratio = (posx - mlineStart) / mLineSize;189 var innerPosX = (innerWidth - stripWidth) * ratio;190 innerPosX = Math.round(innerPosX) * -1 + innerOffsetLeft;191 192 193 return(innerPosX);194 }195 196 197 /**198 * move strip stap to final position199 */200 function moveStripStep(){201 202 if(g_temp.is_strip_moving == false){203 return(false);204 }205 206 var innerPos = g_parent.getInnerStripPos();207 208 if(Math.floor(innerPos) == Math.floor(g_temp.strip_finalPos)){209 stopStripMovingLoop();210 }211 212 //calc step213 var diff = Math.abs(g_temp.strip_finalPos - innerPos);214 215 var dpos;216 if(diff < 1){217 dpos = diff;218 }219 else{220 221 dpos = diff / 4;222 if(dpos > 0 && dpos < 1)223 dpos = 1;224 } 225 226 if(g_temp.strip_finalPos < innerPos)227 dpos = dpos * -1;228 229 var newPos = innerPos + dpos;230 231 g_parent.positionInnerStrip(newPos);232 233 }234 235 236 /**237 * start loop of strip moving238 */239 function startStripMovingLoop(){240 241 if(g_temp.isStripMoving == true)242 return(false);243 244 g_temp.isStripMoving = true;245 g_temp.handle_timeout = setInterval(moveStripStep,10);246 }247 248 /**249 * stop loop of strip moving250 */251 function stopStripMovingLoop(){252 253 if(g_temp.isStripMoving == false)254 return(false);255 256 g_temp.isStripMoving = false;257 g_temp.handle_timeout = clearInterval(g_temp.handle_timeout);258 }259 /**260 * get inner position according the orientation261 * taken by the mouse position262 */263 function getInnerPos(mousePos){264 265 if(g_isVertical == false)266 return getInnerPosX(mousePos);267 else268 return getInnerPosY(mousePos);269 270 }271 272 273 /**274 * move the strip to mouse position on it275 * mousex - mouse position relative to the document276 */277 function moveStripToMousePosition(mousePos){ 278 279 var innerPos = getInnerPos(mousePos);280 281 if(innerPos === null)282 return(false);283 284 g_temp.is_strip_moving = true;285 g_temp.strip_finalPos = innerPos;286 287 startStripMovingLoop();288 }289 ...

Full Screen

Full Screen

stripWordBoundariesSpec.js

Source:stripWordBoundariesSpec.js Github

copy

Full Screen

1import {2 stripWordBoundariesStart,3 stripWordBoundariesEnd,4 stripWordBoundariesEverywhere,5} from "../../../../src/languageProcessing/helpers/sanitize/stripWordBoundaries.js";6describe( "A test to check if word boundaries are removed from words.", function() {7 it( "returns a string with word boundaries in the beginning of the word removed", function() {8 expect( stripWordBoundariesStart( "?keyword" ) ).toBe( "keyword" );9 expect( stripWordBoundariesStart( ".keyword" ) ).toBe( "keyword" );10 expect( stripWordBoundariesStart( ",keyword" ) ).toBe( "keyword" );11 expect( stripWordBoundariesStart( "'keyword" ) ).toBe( "keyword" );12 expect( stripWordBoundariesStart( "(keyword" ) ).toBe( "keyword" );13 expect( stripWordBoundariesStart( ")keyword" ) ).toBe( "keyword" );14 expect( stripWordBoundariesStart( "\"keyword" ) ).toBe( "keyword" );15 expect( stripWordBoundariesStart( "+keyword" ) ).toBe( "keyword" );16 expect( stripWordBoundariesStart( "-keyword" ) ).toBe( "keyword" );17 expect( stripWordBoundariesStart( ";keyword" ) ).toBe( "keyword" );18 expect( stripWordBoundariesStart( "!keyword" ) ).toBe( "keyword" );19 expect( stripWordBoundariesStart( "?keyword" ) ).toBe( "keyword" );20 expect( stripWordBoundariesStart( ":keyword" ) ).toBe( "keyword" );21 expect( stripWordBoundariesStart( "/keyword" ) ).toBe( "keyword" );22 expect( stripWordBoundariesStart( "»keyword" ) ).toBe( "keyword" );23 expect( stripWordBoundariesStart( "«keyword" ) ).toBe( "keyword" );24 expect( stripWordBoundariesStart( "‹keyword" ) ).toBe( "keyword" );25 expect( stripWordBoundariesStart( "›keyword" ) ).toBe( "keyword" );26 expect( stripWordBoundariesStart( "<keyword" ) ).toBe( "keyword" );27 expect( stripWordBoundariesStart( ">keyword" ) ).toBe( "keyword" );28 expect( stripWordBoundariesStart( ">! \"keyword" ) ).toBe( "keyword" );29 expect( stripWordBoundariesStart( "keyword" ) ).toBe( "keyword" );30 } );31 it( "returns a string with word boundaries in the end of the word removed", function() {32 expect( stripWordBoundariesEnd( "keyword." ) ).toBe( "keyword" );33 expect( stripWordBoundariesEnd( "keyword," ) ).toBe( "keyword" );34 expect( stripWordBoundariesEnd( "keyword'" ) ).toBe( "keyword" );35 expect( stripWordBoundariesEnd( "keyword(" ) ).toBe( "keyword" );36 expect( stripWordBoundariesEnd( "keyword)" ) ).toBe( "keyword" );37 expect( stripWordBoundariesEnd( "keyword\"" ) ).toBe( "keyword" );38 expect( stripWordBoundariesEnd( "keyword+" ) ).toBe( "keyword" );39 expect( stripWordBoundariesEnd( "keyword-" ) ).toBe( "keyword" );40 expect( stripWordBoundariesEnd( "keyword;" ) ).toBe( "keyword" );41 expect( stripWordBoundariesEnd( "keyword!" ) ).toBe( "keyword" );42 expect( stripWordBoundariesEnd( "keyword?" ) ).toBe( "keyword" );43 expect( stripWordBoundariesEnd( "keyword:" ) ).toBe( "keyword" );44 expect( stripWordBoundariesEnd( "keyword/" ) ).toBe( "keyword" );45 expect( stripWordBoundariesEnd( "keyword»" ) ).toBe( "keyword" );46 expect( stripWordBoundariesEnd( "keyword«" ) ).toBe( "keyword" );47 expect( stripWordBoundariesEnd( "keyword‹" ) ).toBe( "keyword" );48 expect( stripWordBoundariesEnd( "keyword›" ) ).toBe( "keyword" );49 expect( stripWordBoundariesEnd( "keyword<" ) ).toBe( "keyword" );50 expect( stripWordBoundariesEnd( "keyword>" ) ).toBe( "keyword" );51 expect( stripWordBoundariesEnd( "keyword< ?." ) ).toBe( "keyword" );52 expect( stripWordBoundariesEnd( "keyword" ) ).toBe( "keyword" );53 } );54 it( "returns a string with word-final boundaries removed in an RTL script", function() {55 // Arabic comma56 expect( stripWordBoundariesEnd( "المقاومة،" ) ).toBe( "المقاومة" );57 // Arabic question mark58 expect( stripWordBoundariesEnd( "الجيدة؟" ) ).toBe( "الجيدة" );59 // Arabic semicolon60 expect( stripWordBoundariesEnd( "الجيدة؛" ) ).toBe( "الجيدة" );61 // Urdu full stop62 expect( stripWordBoundariesEnd( "گئے۔" ) ).toBe( "گئے" );63 } );64 it( "returns a string with word boundaries in the end of the word removed", function() {65 expect( stripWordBoundariesEverywhere( "?keyword " ) ).toBe( "keyword" );66 expect( stripWordBoundariesEverywhere( "keyword" ) ).toBe( "keyword" );67 } );...

Full Screen

Full Screen

PageListView.js

Source:PageListView.js Github

copy

Full Screen

1define(function(require, exports, module) {2 // LOAD CLASS3 var Surface = require('famous/core/Surface');4 var Modifier = require('famous/core/Modifier');5 var Transform = require('famous/core/Transform');6 var View = require('famous/core/View');7 var StripListView = require('./StripListView');8 // CONSTRUCTOR9 /**10 * @param (object) options11 * - (int) stripWidth12 * - (int) stripHeight13 * - (int) topOffset14 * @return this15 */16 function PageListView() {17 View.apply(this, arguments);18 _createStripListViews.call(this);19 this._eventInput.pipe(this._eventOutput);20 }21 // EXTENDS FAMOUS VIEW CLASS22 PageListView.prototype = Object.create(View.prototype);23 PageListView.prototype.constructor = PageListView;24 // DEFAULT OPTIONS (refer to this.options into AppView)25 PageListView.DEFAULT_OPTIONS = {26 stripWidth: 320,27 stripHeight: 200,28 topOffset: 150,29 listData: null30 };31 // CUSTOM PRIVATE METHODS32 function _createStripListViews(options) {33 var yOffset;34 this.stripModifiers = [];35 this.stripListViews = [];36 for(var i = 0; i < this.options.listData.length; i++) {37 yOffset = (this.options.stripHeight / 2) * i;38 var stripListView = new StripListView({39 width: this.options.stripWidth,40 height: this.options.stripHeight,41 yOffset: yOffset,42 img: this.options.listData[i].img,43 title: this.options.listData[i].title,44 paragraph: this.options.listData[i].paragraph45 });46 stripListView.pipe(this._eventInput);47 var stripModifier = new Modifier({48 transform: Transform.translate(0, yOffset, -i)49 });50 this.stripListViews.push(stripListView);51 this.stripModifiers.push(stripModifier);52 this._add(stripModifier).add(stripListView);53 }54 this.totalHeight = yOffset + this.options.stripHeight / 2;55 }56 // CUSTOM PUBLIC METHODS57 /**58 * @param (int) y - set translateY59 * @return null60 */61 PageListView.prototype.updateView = function(y)62 {63 this.stripListViews[0].zoom(50);64 var yOffset, percent;65 for(var i = 0; i < this.stripModifiers.length; i++) {66 var stripOffset = this.stripListViews[i].options.yOffset;67 if(-stripOffset >= y) {68 yOffset = stripOffset - (-stripOffset- y);69 percent = yOffset * 100 / this.stripListViews[i].options.height;70 this.stripModifiers[i].setTransform(Transform.translate(0, yOffset, -i));71 if(i + 1 < this.stripListViews.length) {72 this.stripListViews[i + 1].zoom((-stripOffset - y) * 100 / this.stripListViews[i].options.height);73 }74 }else {75 yOffset = stripOffset - (-stripOffset);76 this.stripModifiers[i].setTransform(Transform.translate(0, stripOffset, -i));77 }78 if(-stripOffset > y - (window.innerHeight)) {79 this.stripListViews[i].parallax((-stripOffset - y) / 10);80 }81 }82 };83 /**84 * return the totalHeight caculated into _createStripListViews85 * @param null86 * @return (int) this.totalHeight87 */88 PageListView.prototype.getStripsViewHeight = function()89 {90 return this.totalHeight;91 };92 // EXPORT93 module.exports = PageListView;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1it('test', () => {2 cy.location().should((loc) => {3 expect(loc.hash).to.be.empty4 expect(loc.host).to.eq('example.cypress.io')5 expect(loc.hostname).to.eq('example.cypress.io')6 expect(loc.pathname).to.eq('/commands/location')7 expect(loc.port).to.eq('')8 expect(loc.protocol).to.eq('https:')9 expect(loc.search).to.be.empty10 })11})

Full Screen

Using AI Code Generation

copy

Full Screen

1it('Strip', () => {2 cy.get('.query-list').contains('parent').parent().should('contain', 'ul')3 cy.get('.query-list').contains('parents').parents().should('match', 'body')4 cy.get('.query-list').contains('parents').parents('div').should('have.class', 'query-btn')5 cy.get('.query-list').contains('closest').closest('ul').should('have.class', 'query-list')6 cy.get('.query-list').contains('children').children().should('have.length', 3)7 cy.get('.query-list').contains('children').children('.disabled').should('contain', 'bananas')8 cy.get('.traversal-breadcrumb').children('.active').should('contain', 'Data')9 cy.get('.traversal-drinks-list').find('.coffee').should('have.class', 'third')10 cy.get('.traversal-pagination').find('li').find('a').should('have.length', 7)11 cy.get('.traversal-table').find('tbody').find('tr').first().find('td').first().should('contain', '1')12 cy.get('.traversal-ul').find('li').first().should('contain', 'siamese')13 cy.get('.traversal-order-list').find('li').first().should('contain', '1')14 cy.get('.query-list').contains('siblings').siblings().should('have.length', 2)15 cy.get('.query-list').contains('siblings').siblings('.active').should('contain', 'bananas')16 cy.get('.traversal-tabs').find('.active').siblings('li').should('have.length', 2)17 cy.get('.traversal-pills').find('.active').siblings('li').should('have.length', 2)18})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function () {2 it('Does not do much!', function () {3 cy.get('input').type('Hello World')4 cy.get('input').clear()5 })6})7describe('My First Test', function () {8 it('Does not do much!', function () {9 cy.get('input').type('Hello World')10 cy.get('input').clear()11 cy.get('input').type('Hello World')12 cy.get('input').type('{selectall}')13 cy.get('input').type('{backspace}')14 })15})16describe('My First Test', function () {17 it('Does not do much!', function () {18 cy.get('input').type('Hello World')19 cy.get('input').clear()20 cy.get('input').type('Hello World')21 cy.get('input').type('{selectall}')22 cy.get('input').type('{backspace}')23 cy.get('input').type('Hello World')24 cy.get('input').type('{selectall}')25 cy.get('input').type('{backspace}')26 })27})28describe('My First Test', function () {29 it('Does not do much!', function () {30 cy.get('input').type('Hello World')31 cy.get('input').clear()32 cy.get('input').type('Hello World')33 cy.get('input').type('{selectall}')34 cy.get('input').type('{backspace}')35 cy.get('input').type('Hello World')36 cy.get('input').type('{selectall}')37 cy.get('input').type('{backspace}')38 cy.get('input').type('Hello World')39 cy.get('input').type('{selectall}')40 cy.get('input').type('{backspace}')41 })42})43describe('My First Test', function () {44 it('Does not do much!', function () {

Full Screen

Using AI Code Generation

copy

Full Screen

1it('test', () => {2 cy.get('.navbar-nav').find('li').contains('Docs').click()3 cy.url().should('include', '/docs')4 cy.get('.docs-sidebar').find('li').contains('Overview').click()5 cy.url().should('include', '/overview')6 cy.get('.docs-article').find('h1').contains('Overview').should('be.visible')7})

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.location('hash', {log: false}).then((hash) => {2 cy.location('pathname', {log: false}).then((pathname) => {3 cy.log(pathname + hash);4 cy.visit(pathname + hash, {log: false});5 });6});7cy.location('hash', {log: false}).then((hash) => {8 cy.location('pathname', {log: false}).then((pathname) => {9 cy.log(pathname + hash);10 cy.visit(pathname + hash, {log: false});11 });12});13cy.location('hash', {log: false}).then((hash) => {14 cy.location('pathname', {log: false}).then((pathname) => {15 cy.log(pathname + hash);16 cy.visit(pathname + hash, {log: false});17 });18});19cy.location('hash', {log: false}).then((hash) => {20 cy.location('pathname', {log: false}).then((pathname) => {21 cy.log(pathname + hash);22 cy.visit(pathname + hash, {log: false});23 });24});25cy.location('hash', {log: false}).then((hash) => {26 cy.location('pathname', {log: false}).then((pathname) => {27 cy.log(pathname + hash);28 cy.visit(pathname + hash, {log: false});29 });30});31cy.location('hash', {log: false}).then((hash) => {32 cy.location('pathname', {log: false}).then((pathname) => {33 cy.log(pathname + hash);34 cy.visit(pathname + hash, {log: false});35 });36});37cy.location('hash', {log: false}).then((hash) => {38 cy.location('pathname', {log: false}).then((pathname) => {39 cy.log(pathname + hash);40 cy.visit(pathname + hash, {log: false});

Full Screen

Using AI Code Generation

copy

Full Screen

1it("should strip html tags", () => {2 cy.get("p").then((p) => {3 const text = Cypress.$(p).text();4 expect(text).to.equal(5 );6 });7});

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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