Best JavaScript code snippet using best
zoom-test.js
Source:zoom-test.js
...32 this.zoomDestroy();33};34ZoomTest.prototype.zoomDestroy = function() {35 if(this.zoomElement.data('zoom')) {36 this.zoomElement.zoom('destroy');37 }38};39ZoomTest.prototype.zoomCreate = function(options, element) {40 return (element || this.zoomElement).zoom(options || {} ).data('zoom');41};42ZoomTest.prototype.testInit = function() {43 this.zoomElement.zoom();44 assertTrue(this.zoomElement.is(':mage-zoom'));45};46ZoomTest.prototype.testCreate = function() {47 var zoomInstance = this.zoomCreate(),48 _setZoomData = jsunit.stub(zoomInstance, '_setZoomData'),49 _render = jsunit.stub(zoomInstance, '_render'),50 _bind = jsunit.stub(zoomInstance, '_bind'),51 _hide = jsunit.stub(zoomInstance, '_hide'),52 _largeImageLoaded = jsunit.stub(zoomInstance, '_largeImageLoaded');53 zoomInstance.largeImage = [{54 complete: false55 }];56 zoomInstance._create();57 assertTrue(_setZoomData.callCount === 1);...
mui.zoom.js
Source:mui.zoom.js
1(function($, window) {2 var CLASS_ZOOM = $.className('zoom');3 var CLASS_ZOOM_SCROLLER = $.className('zoom-scroller');4 var SELECTOR_ZOOM = '.' + CLASS_ZOOM;5 var SELECTOR_ZOOM_SCROLLER = '.' + CLASS_ZOOM_SCROLLER;6 var EVENT_PINCH_START = 'pinchstart';7 var EVENT_PINCH = 'pinch';8 var EVENT_PINCH_END = 'pinchend';9 if ('ongesturestart' in window) {10 EVENT_PINCH_START = 'gesturestart';11 EVENT_PINCH = 'gesturechange';12 EVENT_PINCH_END = 'gestureend';13 }14 $.Zoom = function(element, options) {15 var zoom = this;16 zoom.options = $.extend($.Zoom.defaults, options);17 zoom.wrapper = zoom.element = element;18 zoom.scroller = element.querySelector(SELECTOR_ZOOM_SCROLLER);19 zoom.scrollerStyle = zoom.scroller && zoom.scroller.style;20 zoom.zoomer = element.querySelector(SELECTOR_ZOOM);21 zoom.zoomerStyle = zoom.zoomer && zoom.zoomer.style;22 zoom.init = function() {23 //èªå¨å¯ç¨24 $.options.gestureConfig.pinch = true;25 $.options.gestureConfig.doubletap = true;26 zoom.initEvents();27 };28 zoom.initEvents = function(detach) {29 var action = detach ? 'removeEventListener' : 'addEventListener';30 var target = zoom.scroller;31 target[action](EVENT_PINCH_START, zoom.onPinchstart);32 target[action](EVENT_PINCH, zoom.onPinch);33 target[action](EVENT_PINCH_END, zoom.onPinchend);34 target[action]($.EVENT_START, zoom.onTouchstart);35 target[action]($.EVENT_MOVE, zoom.onTouchMove);36 target[action]($.EVENT_CANCEL, zoom.onTouchEnd);37 target[action]($.EVENT_END, zoom.onTouchEnd);38 target[action]('drag', zoom.dragEvent);39 target[action]('doubletap', zoom.doubleTapEvent);40 };41 zoom.dragEvent = function(e) {42 if (imageIsMoved || isGesturing) {43 e.stopPropagation();44 }45 };46 zoom.doubleTapEvent = function(e) {47 zoom.toggleZoom(e.detail.center);48 };49 zoom.transition = function(style, time) {50 time = time || 0;51 style['webkitTransitionDuration'] = time + 'ms';52 return zoom;53 };54 zoom.translate = function(style, x, y) {55 x = x || 0;56 y = y || 0;57 style['webkitTransform'] = 'translate3d(' + x + 'px,' + y + 'px,0px)';58 return zoom;59 };60 zoom.scale = function(style, scale) {61 scale = scale || 1;62 style['webkitTransform'] = 'translate3d(0,0,0) scale(' + scale + ')';63 return zoom;64 };65 zoom.scrollerTransition = function(time) {66 return zoom.transition(zoom.scrollerStyle, time);67 };68 zoom.scrollerTransform = function(x, y) {69 return zoom.translate(zoom.scrollerStyle, x, y);70 };71 zoom.zoomerTransition = function(time) {72 return zoom.transition(zoom.zoomerStyle, time);73 };74 zoom.zoomerTransform = function(scale) {75 return zoom.scale(zoom.zoomerStyle, scale);76 };77 // Gestures78 var scale = 1,79 currentScale = 1,80 isScaling = false,81 isGesturing = false;82 zoom.onPinchstart = function(e) {83 isGesturing = true;84 };85 zoom.onPinch = function(e) {86 if (!isScaling) {87 zoom.zoomerTransition(0);88 isScaling = true;89 }90 scale = (e.detail ? e.detail.scale : e.scale) * currentScale;91 if (scale > zoom.options.maxZoom) {92 scale = zoom.options.maxZoom - 1 + Math.pow((scale - zoom.options.maxZoom + 1), 0.5);93 }94 if (scale < zoom.options.minZoom) {95 scale = zoom.options.minZoom + 1 - Math.pow((zoom.options.minZoom - scale + 1), 0.5);96 }97 zoom.zoomerTransform(scale);98 };99 zoom.onPinchend = function(e) {100 scale = Math.max(Math.min(scale, zoom.options.maxZoom), zoom.options.minZoom);101 zoom.zoomerTransition(zoom.options.speed).zoomerTransform(scale);102 currentScale = scale;103 isScaling = false;104 };105 zoom.setZoom = function(newScale) {106 scale = currentScale = newScale;107 zoom.scrollerTransition(zoom.options.speed).scrollerTransform(0, 0);108 zoom.zoomerTransition(zoom.options.speed).zoomerTransform(scale);109 };110 zoom.toggleZoom = function(position, speed) {111 if (typeof position === 'number') {112 speed = position;113 position = undefined;114 }115 speed = typeof speed === 'undefined' ? zoom.options.speed : speed;116 if (scale && scale !== 1) {117 scale = currentScale = 1;118 zoom.scrollerTransition(speed).scrollerTransform(0, 0);119 } else {120 scale = currentScale = zoom.options.maxZoom;121 if (position) {122 var offset = $.offset(zoom.zoomer);123 var top = offset.top;124 var left = offset.left;125 var offsetX = (position.x - left) * scale;126 var offsetY = (position.y - top) * scale;127 this._cal();128 if (offsetX >= imageMaxX && offsetX <= (imageMaxX + wrapperWidth)) { //center129 offsetX = imageMaxX - offsetX + wrapperWidth / 2;130 } else if (offsetX < imageMaxX) { //left131 offsetX = imageMaxX - offsetX + wrapperWidth / 2;132 } else if (offsetX > (imageMaxX + wrapperWidth)) { //right133 offsetX = imageMaxX + wrapperWidth - offsetX - wrapperWidth / 2;134 }135 if (offsetY >= imageMaxY && offsetY <= (imageMaxY + wrapperHeight)) { //middle136 offsetY = imageMaxY - offsetY + wrapperHeight / 2;137 } else if (offsetY < imageMaxY) { //top138 offsetY = imageMaxY - offsetY + wrapperHeight / 2;139 } else if (offsetY > (imageMaxY + wrapperHeight)) { //bottom140 offsetY = imageMaxY + wrapperHeight - offsetY - wrapperHeight / 2;141 }142 offsetX = Math.min(Math.max(offsetX, imageMinX), imageMaxX);143 offsetY = Math.min(Math.max(offsetY, imageMinY), imageMaxY);144 zoom.scrollerTransition(speed).scrollerTransform(offsetX, offsetY);145 } else {146 zoom.scrollerTransition(speed).scrollerTransform(0, 0);147 }148 }149 zoom.zoomerTransition(speed).zoomerTransform(scale);150 };151 zoom._cal = function() {152 wrapperWidth = zoom.wrapper.offsetWidth;153 wrapperHeight = zoom.wrapper.offsetHeight;154 imageWidth = zoom.zoomer.offsetWidth;155 imageHeight = zoom.zoomer.offsetHeight;156 var scaledWidth = imageWidth * scale;157 var scaledHeight = imageHeight * scale;158 imageMinX = Math.min((wrapperWidth / 2 - scaledWidth / 2), 0);159 imageMaxX = -imageMinX;160 imageMinY = Math.min((wrapperHeight / 2 - scaledHeight / 2), 0);161 imageMaxY = -imageMinY;162 };163 var wrapperWidth, wrapperHeight, imageIsTouched, imageIsMoved, imageCurrentX, imageCurrentY, imageMinX, imageMinY, imageMaxX, imageMaxY, imageWidth, imageHeight, imageTouchesStart = {},164 imageTouchesCurrent = {},165 imageStartX, imageStartY, velocityPrevPositionX, velocityPrevTime, velocityX, velocityPrevPositionY, velocityY;166 zoom.onTouchstart = function(e) {167 e.preventDefault();168 imageIsTouched = true;169 imageTouchesStart.x = e.type === $.EVENT_START ? e.targetTouches[0].pageX : e.pageX;170 imageTouchesStart.y = e.type === $.EVENT_START ? e.targetTouches[0].pageY : e.pageY;171 };172 zoom.onTouchMove = function(e) {173 e.preventDefault();174 if (!imageIsTouched) return;175 if (!imageIsMoved) {176 wrapperWidth = zoom.wrapper.offsetWidth;177 wrapperHeight = zoom.wrapper.offsetHeight;178 imageWidth = zoom.zoomer.offsetWidth;179 imageHeight = zoom.zoomer.offsetHeight;180 var translate = $.parseTranslateMatrix($.getStyles(zoom.scroller, 'webkitTransform'));181 imageStartX = translate.x || 0;182 imageStartY = translate.y || 0;183 zoom.scrollerTransition(0);184 }185 var scaledWidth = imageWidth * scale;186 var scaledHeight = imageHeight * scale;187 if (scaledWidth < wrapperWidth && scaledHeight < wrapperHeight) return;188 imageMinX = Math.min((wrapperWidth / 2 - scaledWidth / 2), 0);189 imageMaxX = -imageMinX;190 imageMinY = Math.min((wrapperHeight / 2 - scaledHeight / 2), 0);191 imageMaxY = -imageMinY;192 imageTouchesCurrent.x = e.type === $.EVENT_MOVE ? e.targetTouches[0].pageX : e.pageX;193 imageTouchesCurrent.y = e.type === $.EVENT_MOVE ? e.targetTouches[0].pageY : e.pageY;194 if (!imageIsMoved && !isScaling) {195 // if (Math.abs(imageTouchesCurrent.y - imageTouchesStart.y) < Math.abs(imageTouchesCurrent.x - imageTouchesStart.x)) {196 //TODO æ¤å¤éè¦ä¼åï¼å½éå°é¿å¾ï¼éè¦ä¸ä¸æ»å¨æ¶ï¼ä¸åå¤æä¼å¯¼è´æ»å¨ä¸æµç
197 if (198 (Math.floor(imageMinX) === Math.floor(imageStartX) && imageTouchesCurrent.x < imageTouchesStart.x) ||199 (Math.floor(imageMaxX) === Math.floor(imageStartX) && imageTouchesCurrent.x > imageTouchesStart.x)200 ) {201 imageIsTouched = false;202 return;203 }204 // }205 }206 imageIsMoved = true;207 imageCurrentX = imageTouchesCurrent.x - imageTouchesStart.x + imageStartX;208 imageCurrentY = imageTouchesCurrent.y - imageTouchesStart.y + imageStartY;209 if (imageCurrentX < imageMinX) {210 imageCurrentX = imageMinX + 1 - Math.pow((imageMinX - imageCurrentX + 1), 0.8);211 }212 if (imageCurrentX > imageMaxX) {213 imageCurrentX = imageMaxX - 1 + Math.pow((imageCurrentX - imageMaxX + 1), 0.8);214 }215 if (imageCurrentY < imageMinY) {216 imageCurrentY = imageMinY + 1 - Math.pow((imageMinY - imageCurrentY + 1), 0.8);217 }218 if (imageCurrentY > imageMaxY) {219 imageCurrentY = imageMaxY - 1 + Math.pow((imageCurrentY - imageMaxY + 1), 0.8);220 }221 //Velocity222 if (!velocityPrevPositionX) velocityPrevPositionX = imageTouchesCurrent.x;223 if (!velocityPrevPositionY) velocityPrevPositionY = imageTouchesCurrent.y;224 if (!velocityPrevTime) velocityPrevTime = $.now();225 velocityX = (imageTouchesCurrent.x - velocityPrevPositionX) / ($.now() - velocityPrevTime) / 2;226 velocityY = (imageTouchesCurrent.y - velocityPrevPositionY) / ($.now() - velocityPrevTime) / 2;227 if (Math.abs(imageTouchesCurrent.x - velocityPrevPositionX) < 2) velocityX = 0;228 if (Math.abs(imageTouchesCurrent.y - velocityPrevPositionY) < 2) velocityY = 0;229 velocityPrevPositionX = imageTouchesCurrent.x;230 velocityPrevPositionY = imageTouchesCurrent.y;231 velocityPrevTime = $.now();232 zoom.scrollerTransform(imageCurrentX, imageCurrentY);233 };234 zoom.onTouchEnd = function(e) {235 if (!e.touches.length) {236 isGesturing = false;237 }238 if (!imageIsTouched || !imageIsMoved) {239 imageIsTouched = false;240 imageIsMoved = false;241 return;242 }243 imageIsTouched = false;244 imageIsMoved = false;245 var momentumDurationX = 300;246 var momentumDurationY = 300;247 var momentumDistanceX = velocityX * momentumDurationX;248 var newPositionX = imageCurrentX + momentumDistanceX;249 var momentumDistanceY = velocityY * momentumDurationY;250 var newPositionY = imageCurrentY + momentumDistanceY;251 if (velocityX !== 0) momentumDurationX = Math.abs((newPositionX - imageCurrentX) / velocityX);252 if (velocityY !== 0) momentumDurationY = Math.abs((newPositionY - imageCurrentY) / velocityY);253 var momentumDuration = Math.max(momentumDurationX, momentumDurationY);254 imageCurrentX = newPositionX;255 imageCurrentY = newPositionY;256 var scaledWidth = imageWidth * scale;257 var scaledHeight = imageHeight * scale;258 imageMinX = Math.min((wrapperWidth / 2 - scaledWidth / 2), 0);259 imageMaxX = -imageMinX;260 imageMinY = Math.min((wrapperHeight / 2 - scaledHeight / 2), 0);261 imageMaxY = -imageMinY;262 imageCurrentX = Math.max(Math.min(imageCurrentX, imageMaxX), imageMinX);263 imageCurrentY = Math.max(Math.min(imageCurrentY, imageMaxY), imageMinY);264 zoom.scrollerTransition(momentumDuration).scrollerTransform(imageCurrentX, imageCurrentY);265 };266 zoom.destroy = function() {267 zoom.initEvents(true); //detach268 delete $.data[zoom.wrapper.getAttribute('data-zoomer')];269 zoom.wrapper.setAttribute('data-zoomer', '');270 }271 zoom.init();272 return zoom;273 };274 $.Zoom.defaults = {275 speed: 300,276 maxZoom: 3,277 minZoom: 1,278 };279 $.fn.zoom = function(options) {280 var zoomApis = [];281 this.each(function() {282 var zoomApi = null;283 var self = this;284 var id = self.getAttribute('data-zoomer');285 if (!id) {286 id = ++$.uuid;287 $.data[id] = zoomApi = new $.Zoom(self, options);288 self.setAttribute('data-zoomer', id);289 } else {290 zoomApi = $.data[id];291 }292 zoomApis.push(zoomApi);293 });294 return zoomApis.length === 1 ? zoomApis[0] : zoomApis;295 };...
c3ext.js
Source:c3ext.js
1var c3ext = {};2c3ext.generate = function (options) {3 if (options.zoom2 != null) {4 zoom2_reducers = options.zoom2.reducers || {};5 zoom2_enabled = options.zoom2.enabled;6 _zoom2_factor = options.zoom2.factor || 1;7 _zoom2_maxItems = options.zoom2.maxItems;8 }9 if (!zoom2_enabled) {10 return c3.generate(options);11 }12 var originalData = Q.copy(options.data);13 var zoom2_reducers;14 var zoom2_enabled;15 var _zoom2_maxItems;16 if (_zoom2_maxItems == null) {17 var el = d3.select(options.bindto)[0][0];18 if (el != null) {19 var availWidth = el.clientWidth;20 var pointSize = 20;21 _zoom2_maxItems = Math.ceil(availWidth / pointSize);22 }23 if (_zoom2_maxItems == null || _zoom2_maxItems < 10) {24 _zoom2_maxItems = 10;25 }26 }27 function onZoomChanged(e) {28 refresh();29 }30 var zoom2 = c3ext.ZoomBehavior({ changed: onZoomChanged, bindto: options.bindto });31 zoom2.enhance = function () {32 _zoom2_maxItems *= 2;33 var totalItems = zoom2.getZoom().totalItems;34 if (_zoom2_maxItems > totalItems)35 _zoom2_maxItems = totalItems;36 refresh();37 }38 zoom2.dehance = function () {39 _zoom2_maxItems = Math.ceil(_zoom2_maxItems / 2) + 1;40 refresh();41 }42 zoom2.maxItems = function () { return _zoom2_maxItems; };43 function zoomAndReduceData(list, zoomRange, func, maxItems) {44 //var maxItems = 10;//Math.ceil(10 * zoomFactor);45 var list2 = list.slice(zoomRange[0], zoomRange[1]);46 var chunkSize = 1;47 var list3 = list2;48 if (list3.length > maxItems) {49 var chunkSize = Math.ceil(list2.length / maxItems);50 list3 = list3.splitIntoChunksOf(chunkSize).map(func);51 }52 //console.log("x" + getCurrentZoomLevel() + ", maxItems=" + maxItems + " chunkSize=" + chunkSize + " totalBefore=" + list2.length + ", totalAfter=" + list3.length);53 return list3;54 }55 function first(t) { return t[0]; }56 var getDataForZoom = function (data) {57 if (data.columns == null || data.columns.length == 0)58 return;59 var zoomInfo = zoom2.getZoom();60 if (zoomInfo.totalItems != data.columns[0].length - 1) {61 zoom2.setOptions({ totalItems: data.columns[0].length - 1 });62 zoomInfo = zoom2.getZoom();63 }64 data.columns = originalData.columns.map(function (column) {65 var name = column[0];66 var reducer = zoom2_reducers[name] || first; //by default take the first67 var values = column.slice(1);68 var newValues = zoomAndReduceData(values, zoomInfo.currentZoom, reducer, _zoom2_maxItems);69 return [name].concat(newValues);70 });71 return data;72 };73 getDataForZoom(options.data);74 var chart = c3.generate(options);75 var _chart_load_org = chart.load.bind(chart);76 chart.zoom2 = zoom2;77 chart.load = function (data) {78 if (data.unload) {79 unload(data.unload);80 delete data.unload;81 }82 Q.copy(data, originalData);83 refresh();84 }85 chart.unload = function (names) {86 unload(names);87 refresh();88 }89 function unload(names) {90 originalData.columns.removeAll(function (t) { names.contains(t); });91 }92 function refresh() {93 var data = Q.copy(originalData)94 getDataForZoom(data);95 _chart_load_org(data);96 };97 return chart;98}99c3ext.ZoomBehavior = function (options) {100 var zoom = { __type: "ZoomBehavior" };101 var _zoom2_factor;102 var _left;103 var totalItems;104 var currentZoom;105 var bindto = options.bindto;106 var _zoomChanged = options.changed || function () { };107 var element;108 var mousewheelTimer;109 var deltaY = 0;110 var leftRatio = 0;111 zoom.setOptions = function (options) {112 if (options == null)113 options = {};114 _zoom2_factor = options.factor || 1;115 _left = 0;116 totalItems = options.totalItems || 0;117 currentZoom = [0, totalItems];118 _zoomChanged = options.changed || _zoomChanged;119 }120 zoom.setOptions(options);121 function verifyZoom(newZoom) {122 //newZoom.sort();123 if (newZoom[1] > totalItems) {124 var diff = newZoom[1] - totalItems;125 newZoom[0] -= diff;126 newZoom[1] -= diff;127 }128 if (newZoom[0] < 0) {129 var diff = newZoom[0] * -1;130 newZoom[0] += diff;131 newZoom[1] += diff;132 }133 if (newZoom[1] > totalItems)134 newZoom[1] = totalItems;135 if (newZoom[0] < 0)136 newZoom[0] = 0;137 }138 function zoomAndPan(zoomFactor, left) {139 var itemsToShow = Math.ceil(totalItems / zoomFactor);140 var newZoom = [left, left + itemsToShow];141 verifyZoom(newZoom);142 currentZoom = newZoom;143 onZoomChanged();144 }145 function onZoomChanged() {146 if (_zoomChanged != null)147 _zoomChanged(zoom.getZoom());148 }149 function applyZoomAndPan() {150 zoomAndPan(_zoom2_factor, _left);151 }152 function getItemsToShow() {153 var itemsToShow = Math.ceil(totalItems / _zoom2_factor);154 return itemsToShow;155 }156 zoom.getZoom = function () {157 return { totalItems: totalItems, currentZoom: currentZoom.slice() };158 }159 zoom.factor = function (factor, skipDraw) {160 if (arguments.length == 0)161 return _zoom2_factor;162 _zoom2_factor = factor;163 if (_zoom2_factor < 1)164 _zoom2_factor = 1;165 if (skipDraw)166 return;167 applyZoomAndPan();168 }169 zoom.left = function (left, skipDraw) {170 if (arguments.length == 0)171 return _left;172 _left = left;173 if (_left < 0)174 _left = 0;175 var pageSize = getItemsToShow();176 //_left += pageSize;177 if (_left + pageSize > totalItems)178 _left = totalItems - pageSize;179 console.log({ left: _left, pageSize: pageSize });180 if (skipDraw)181 return;182 applyZoomAndPan();183 }184 zoom.zoomAndPanByRatio = function (zoomRatio, panRatio) {185 var pageSize = getItemsToShow();186 var leftOffset = Math.round(pageSize * panRatio);187 var mouseLeft = _left + leftOffset;188 zoom.factor(zoom.factor() * zoomRatio, true);189 var finalLeft = mouseLeft;190 if (zoomRatio != 1) {191 var pageSize2 = getItemsToShow();192 var leftOffset2 = Math.round(pageSize2 * panRatio);193 finalLeft = mouseLeft - leftOffset2;194 }195 zoom.left(finalLeft, true);196 applyZoomAndPan();197 }198 zoom.zoomIn = function () {199 zoom.zoomAndPanByRatio(2, 0);200 }201 zoom.zoomOut = function () {202 zoom.zoomAndPanByRatio(0.5, 0);203 }204 zoom.panLeft = function () {205 zoom.zoomAndPanByRatio(1, -1);206 }207 zoom.panRight = function () {208 zoom.zoomAndPanByRatio(1, 1);209 }210 zoom.reset = function () {211 _left = 0;212 _zoom2_factor = 1;213 applyZoomAndPan();214 }215 function doZoom() {216 if (deltaY != 0) {217 var maxDelta = 10;218 var multiply = (maxDelta + deltaY) / maxDelta;219 //var factor = chart.zoom2.factor()*multiply;220 //factor= Math.ceil(factor*100) / 100;221 console.log({ deltaY: deltaY, multiply: multiply });222 zoom.zoomAndPanByRatio(multiply, leftRatio);//0.5);//leftRatio);223 deltaY = 0;224 }225 }226 function element_mousewheel(e) {227 deltaY += e.deltaY;228 leftRatio = (e.offsetX - 70) / (e.currentTarget.offsetWidth - 70);229 //console.log({ "e.offsetX": e.offsetX, "e.currentTarget.offsetWidth": e.currentTarget.offsetWidth, leftRatio: leftRatio });230 mousewheelTimer.set(150);231 e.preventDefault();232 }233 if (bindto != null) {234 element = $(options.bindto);235 if (element.mousewheel) {236 mousewheelTimer = new Timer(doZoom);237 element.mousewheel(element_mousewheel);238 }239 }240 return zoom;241}242if (typeof (Q) == "undefined") {243 var Q = function () {244 };245 Q.copy = function (src, target, options, depth) {246 ///<summary>Copies an object into a target object, recursively cloning any object or array in the way, overwrite=true will overwrite a primitive field value even if exists</summary>247 ///<param name="src" />248 ///<param name="target" />249 ///<param name="options" type="Object">{ overwrite:false }</param>250 ///<returns type="Object">The copied object</returns>251 if (depth == null)252 depth = 0;253 if (depth == 100) {254 console.warn("Q.copy is in depth of 100 - possible circular reference")255 }256 options = options || { overwrite: false };257 if (src == target || src == null)258 return target;259 if (typeof (src) != "object") {260 if (options.overwrite || target == null)261 return src;262 return target;263 }264 if (typeof (src.clone) == "function") {265 if (options.overwrite || target == null)266 return src.clone();267 return target;268 }269 if (target == null) {270 if (src instanceof Array)271 target = [];272 else273 target = {};274 }275 if (src instanceof Array) {276 for (var i = 0; i < src.length; i++) {277 var item = src[i];278 var item2 = target[i];279 item2 = Q.copy(item, item2, options, depth + 1);280 target[i] = item2;281 }282 target.splice(src.length, target.length - src.length);283 return target;284 }285 for (var p in src) {286 var value = src[p];287 var value2 = target[p];288 value2 = Q.copy(value, value2, options, depth + 1);289 target[p] = value2;290 }291 return target;292 }293}294if (typeof (Timer) == "undefined") {295 var Timer = function (action, ms) {296 this.action = action;297 if (ms != null)298 this.set(ms);299 }300 Timer.prototype.set = function (ms) {301 if (ms == null)302 ms = this._ms;303 else304 this._ms = ms;305 this.clear();306 if (ms == null)307 return;308 this.timeout = window.setTimeout(this.onTick.bind(this), ms);309 }310 Timer.prototype.onTick = function () {311 this.clear();312 this.action();313 }314 Timer.prototype.clear = function (ms) {315 if (this.timeout == null)316 return;317 window.clearTimeout(this.timeout);318 this.timeout = null;319 }320}321if (typeof(Array.prototype.splitIntoChunksOf)=="undefined") {322 Array.prototype.splitIntoChunksOf = function (countInEachChunk) {323 var chunks = Math.ceil(this.length / countInEachChunk);324 var list = [];325 for (var i = 0; i < this.length; i += countInEachChunk) {326 list.push(this.slice(i, i + countInEachChunk));327 }328 return list;329 }...
zoom_manager.js
Source:zoom_manager.js
1// Copyright 2015 The Chromium Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js';5import {BrowserApi} from './browser_api.js';6// Abstract parent of classes that manage updating the browser with zoom changes7// and/or updating the viewer's zoom when the browser zoom changes.8export class ZoomManager {9 /**10 * @param {function():number} getViewportZoom Callback to get the viewport's11 * current zoom level.12 * @param {number} initialZoom The initial browser zoom level.13 */14 constructor(getViewportZoom, initialZoom) {15 if (this.constructor === ZoomManager) {16 throw new TypeError('Instantiated abstract class: ZoomManager');17 }18 /** @private {number} */19 this.browserZoom_ = initialZoom;20 /** @private {function():number} */21 this.getViewportZoom_ = getViewportZoom;22 /** @private {!EventTarget} */23 this.eventTarget_ = new EventTarget();24 }25 /** @return {!EventTarget} */26 getEventTarget() {27 return this.eventTarget_;28 }29 /**30 * Creates the appropriate kind of zoom manager given the zoom behavior.31 * @param {BrowserApi.ZoomBehavior} zoomBehavior How to manage zoom.32 * @param {function():number} getViewportZoom A function that gets the current33 * viewport zoom.34 * @param {function(number):Promise} setBrowserZoomFunction A function that35 * sets the browser zoom to the provided value.36 * @param {number} initialZoom The initial browser zoom level.37 */38 static create(39 zoomBehavior, getViewportZoom, setBrowserZoomFunction, initialZoom) {40 switch (zoomBehavior) {41 case BrowserApi.ZoomBehavior.MANAGE:42 return new ActiveZoomManager(43 getViewportZoom, setBrowserZoomFunction, initialZoom);44 case BrowserApi.ZoomBehavior.PROPAGATE_PARENT:45 return new EmbeddedZoomManager(getViewportZoom, initialZoom);46 default:47 return new InactiveZoomManager(getViewportZoom, initialZoom);48 }49 }50 /**51 * Invoked when a browser-initiated zoom-level change occurs.52 * @param {number} newZoom the zoom level to zoom to.53 */54 onBrowserZoomChange(newZoom) {}55 /** Invoked when an extension-initiated zoom-level change occurs. */56 onPdfZoomChange() {}57 /**58 * Combines the internal pdf zoom and the browser zoom to59 * produce the total zoom level for the viewer.60 * @param {number} internalZoom the zoom level internal to the viewer.61 * @return {number} the total zoom level.62 */63 applyBrowserZoom(internalZoom) {64 return this.browserZoom_ * internalZoom;65 }66 /**67 * Given a zoom level, return the internal zoom level needed to68 * produce that zoom level.69 * @param {number} totalZoom the total zoom level.70 * @return {number} the zoom level internal to the viewer.71 */72 internalZoomComponent(totalZoom) {73 return totalZoom / this.browserZoom_;74 }75 /**76 * Returns whether two numbers are approximately equal.77 * @param {number} a The first number.78 * @param {number} b The second number.79 */80 floatingPointEquals(a, b) {81 const MIN_ZOOM_DELTA = 0.01;82 // If the zoom level is close enough to the current zoom level, don't83 // change it. This avoids us getting into an infinite loop of zoom changes84 // due to floating point error.85 return Math.abs(a - b) <= MIN_ZOOM_DELTA;86 }87}88// Has no control over the browser's zoom and does not respond to browser zoom89// changes.90export class InactiveZoomManager extends ZoomManager {}91// ActiveZoomManager controls the browser's zoom.92class ActiveZoomManager extends ZoomManager {93 /**94 * Constructs a ActiveZoomManager.95 * @param {function():number} getViewportZoom A function that gets the current96 * viewport zoom level97 * @param {function(number):Promise} setBrowserZoomFunction A function that98 * sets the browser zoom to the provided value.99 * @param {number} initialZoom The initial browser zoom level.100 */101 constructor(getViewportZoom, setBrowserZoomFunction, initialZoom) {102 super(getViewportZoom, initialZoom);103 /** @private {function(number):Promise} */104 this.setBrowserZoomFunction_ = setBrowserZoomFunction;105 /** @private {?Promise} */106 this.changingBrowserZoom_ = null;107 }108 /**109 * Invoked when a browser-initiated zoom-level change occurs.110 * @param {number} newZoom the zoom level to zoom to.111 */112 onBrowserZoomChange(newZoom) {113 // If we are changing the browser zoom level, ignore any browser zoom level114 // change events. Either, the change occurred before our update and will be115 // overwritten, or the change being reported is the change we are making,116 // which we have already handled.117 if (this.changingBrowserZoom_) {118 return;119 }120 if (this.floatingPointEquals(this.browserZoom_, newZoom)) {121 return;122 }123 this.browserZoom_ = newZoom;124 this.eventTarget_.dispatchEvent(125 new CustomEvent('set-zoom', {detail: newZoom}));126 }127 /**128 * Invoked when an extension-initiated zoom-level change occurs.129 * @override130 */131 onPdfZoomChange() {132 // If we are already changing the browser zoom level in response to a133 // previous extension-initiated zoom-level change, ignore this zoom change.134 // Once the browser zoom level is changed, we check whether the extension's135 // zoom level matches the most recently sent zoom level.136 if (this.changingBrowserZoom_) {137 return;138 }139 const viewportZoom = this.getViewportZoom_();140 if (this.floatingPointEquals(this.browserZoom_, viewportZoom)) {141 return;142 }143 this.changingBrowserZoom_ =144 this.setBrowserZoomFunction_(viewportZoom).then(() => {145 this.browserZoom_ = viewportZoom;146 this.changingBrowserZoom_ = null;147 // The extension's zoom level may have changed while the browser zoom148 // change was in progress. We call back into onPdfZoomChange to ensure149 // the browser zoom is up to date.150 this.onPdfZoomChange();151 });152 }153 /**154 * Combines the internal pdf zoom and the browser zoom to155 * produce the total zoom level for the viewer.156 * @param {number} internalZoom the zoom level internal to the viewer.157 * @return {number} the total zoom level.158 */159 applyBrowserZoom(internalZoom) {160 // The internal zoom and browser zoom are changed together, so the161 // browser zoom is already applied.162 return internalZoom;163 }164 /**165 * Given a zoom level, return the internal zoom level needed to166 * produce that zoom level.167 * @param {number} totalZoom the total zoom level.168 * @return {number} the zoom level internal to the viewer.169 */170 internalZoomComponent(totalZoom) {171 // The internal zoom and browser zoom are changed together, so the172 // internal zoom is the total zoom.173 return totalZoom;174 }175}176// Responds to changes in the browser zoom, but does not control the browser177// zoom.178class EmbeddedZoomManager extends ZoomManager {179 /**180 * Invoked when a browser-initiated zoom-level change occurs.181 * @param {number} newZoom the new browser zoom level.182 */183 onBrowserZoomChange(newZoom) {184 const oldZoom = this.browserZoom_;185 this.browserZoom_ = newZoom;186 this.eventTarget_.dispatchEvent(187 new CustomEvent('update-zoom-from-browser', {detail: oldZoom}));188 }...
browser_api.js
Source:browser_api.js
1// Copyright 2015 The Chromium Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4import {assert} from 'chrome://resources/js/assert.m.js';5/**6 * @param {!Object} streamInfo The stream object pointing to the data contained7 * in the PDF.8 * @return {Promise<number>} A promise that will resolve to the default zoom9 * factor.10 */11function lookupDefaultZoom(streamInfo) {12 // Webviews don't run in tabs so |streamInfo.tabId| is -1 when running within13 // a webview.14 if (!chrome.tabs || streamInfo.tabId < 0) {15 return Promise.resolve(1);16 }17 return new Promise(function(resolve, reject) {18 chrome.tabs.getZoomSettings(streamInfo.tabId, function(zoomSettings) {19 resolve(zoomSettings.defaultZoomFactor);20 });21 });22}23/**24 * Returns a promise that will resolve to the initial zoom factor25 * upon starting the plugin. This may differ from the default zoom26 * if, for example, the page is zoomed before the plugin is run.27 * @param {!Object} streamInfo The stream object pointing to the data contained28 * in the PDF.29 * @return {Promise<number>} A promise that will resolve to the initial zoom30 * factor.31 */32function lookupInitialZoom(streamInfo) {33 // Webviews don't run in tabs so |streamInfo.tabId| is -1 when running within34 // a webview.35 if (!chrome.tabs || streamInfo.tabId < 0) {36 return Promise.resolve(1);37 }38 return new Promise(function(resolve, reject) {39 chrome.tabs.getZoom(streamInfo.tabId, resolve);40 });41}42// A class providing an interface to the browser.43export class BrowserApi {44 /**45 * @param {!Object} streamInfo The stream object which points to the data46 * contained in the PDF.47 * @param {number} defaultZoom The default browser zoom.48 * @param {number} initialZoom The initial browser zoom49 * upon starting the plugin.50 * @param {BrowserApi.ZoomBehavior} zoomBehavior How to manage zoom.51 */52 constructor(streamInfo, defaultZoom, initialZoom, zoomBehavior) {53 this.streamInfo_ = streamInfo;54 this.defaultZoom_ = defaultZoom;55 this.initialZoom_ = initialZoom;56 this.zoomBehavior_ = zoomBehavior;57 }58 /**59 * @param {!Object} streamInfo The stream object pointing to the data60 * contained in the PDF.61 * @param {BrowserApi.ZoomBehavior} zoomBehavior How to manage zoom.62 * @return {Promise<BrowserApi>} A promise to a BrowserApi.63 */64 static create(streamInfo, zoomBehavior) {65 return Promise66 .all([lookupDefaultZoom(streamInfo), lookupInitialZoom(streamInfo)])67 .then(function(zoomFactors) {68 return new BrowserApi(69 streamInfo, zoomFactors[0], zoomFactors[1], zoomBehavior);70 });71 }72 /**73 * @return {Object} The stream info object pointing to the data contained in74 * the PDF.75 */76 getStreamInfo() {77 return this.streamInfo_;78 }79 /**80 * Sets the browser zoom.81 * @param {number} zoom The zoom factor to send to the browser.82 * @return {Promise} A promise that will be resolved when the browser zoom83 * has been updated.84 */85 setZoom(zoom) {86 assert(87 this.zoomBehavior_ === BrowserApi.ZoomBehavior.MANAGE,88 'Viewer does not manage browser zoom.');89 return new Promise((resolve, reject) => {90 chrome.tabs.setZoom(this.streamInfo_.tabId, zoom, resolve);91 });92 }93 /** @return {number} The default browser zoom factor. */94 getDefaultZoom() {95 return this.defaultZoom_;96 }97 /** @return {number} The initial browser zoom factor. */98 getInitialZoom() {99 return this.initialZoom_;100 }101 /** @return {BrowserApi.ZoomBehavior} How to manage zoom. */102 getZoomBehavior() {103 return this.zoomBehavior_;104 }105 /**106 * Adds an event listener to be notified when the browser zoom changes.107 *108 * @param {!Function} listener The listener to be called with the new zoom109 * factor.110 */111 addZoomEventListener(listener) {112 if (!(this.zoomBehavior_ === BrowserApi.ZoomBehavior.MANAGE ||113 this.zoomBehavior_ === BrowserApi.ZoomBehavior.PROPAGATE_PARENT)) {114 return;115 }116 chrome.tabs.onZoomChange.addListener(info => {117 const zoomChangeInfo =118 /** @type {{tabId: number, newZoomFactor: number}} */ (info);119 if (zoomChangeInfo.tabId !== this.streamInfo_.tabId) {120 return;121 }122 listener(zoomChangeInfo.newZoomFactor);123 });124 }125}126/**127 * Enumeration of ways to manage zoom changes.128 * @enum {number}129 */130BrowserApi.ZoomBehavior = {131 NONE: 0,132 MANAGE: 1,133 PROPAGATE_PARENT: 2134};135/**136 * Creates a BrowserApi for an extension running as a mime handler.137 * @return {!Promise<!BrowserApi>} A promise to a BrowserApi instance138 * constructed using the mimeHandlerPrivate API.139 */140function createBrowserApiForMimeHandlerView() {141 return new Promise(function(resolve, reject) {142 chrome.mimeHandlerPrivate.getStreamInfo(resolve);143 })144 .then(function(streamInfo) {145 const promises = [];146 let zoomBehavior = BrowserApi.ZoomBehavior.NONE;147 if (streamInfo.tabId !== -1) {148 zoomBehavior = streamInfo.embedded ?149 BrowserApi.ZoomBehavior.PROPAGATE_PARENT :150 BrowserApi.ZoomBehavior.MANAGE;151 promises.push(new Promise(function(resolve) {152 chrome.tabs.get(streamInfo.tabId, resolve);153 }).then(function(tab) {154 if (tab) {155 streamInfo.tabUrl = tab.url;156 }157 }));158 }159 if (zoomBehavior === BrowserApi.ZoomBehavior.MANAGE) {160 promises.push(new Promise(function(resolve) {161 chrome.tabs.setZoomSettings(162 streamInfo.tabId, {mode: 'manual', scope: 'per-tab'}, resolve);163 }));164 }165 return Promise.all(promises).then(function() {166 return BrowserApi.create(streamInfo, zoomBehavior);167 });168 });169}170/**171 * Creates a BrowserApi instance for an extension not running as a mime handler.172 * @return {!Promise<!BrowserApi>} A promise to a BrowserApi instance173 * constructed from the URL.174 */175function createBrowserApiForPrintPreview() {176 const url = window.location.search.substring(1);177 const streamInfo = {178 streamUrl: url,179 originalUrl: url,180 responseHeaders: {},181 embedded: window.parent !== window,182 tabId: -1,183 };184 return new Promise(function(resolve, reject) {185 if (!chrome.tabs) {186 resolve();187 return;188 }189 chrome.tabs.getCurrent(function(tab) {190 streamInfo.tabId = tab.id;191 streamInfo.tabUrl = tab.url;192 resolve();193 });194 })195 .then(function() {196 return BrowserApi.create(streamInfo, BrowserApi.ZoomBehavior.NONE);197 });198}199/**200 * @return {!Promise<!BrowserApi>} A promise to a BrowserApi instance for the201 * current environment.202 */203export function createBrowserApi() {204 if (location.origin === 'chrome://print') {205 return createBrowserApiForPrintPreview();206 }207 return createBrowserApiForMimeHandlerView();...
Zoom.js
Source:Zoom.js
1/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for2 * full list of contributors). Published under the 2-clause BSD license.3 * See license.txt in the OpenLayers distribution or repository for the4 * full text of the license. */5/**6 * @requires OpenLayers/Control.js7 * @requires OpenLayers/Events/buttonclick.js8 */9/**10 * Class: OpenLayers.Control.Zoom11 * The Zoom control is a pair of +/- links for zooming in and out.12 *13 * Inherits from:14 * - <OpenLayers.Control>15 */16OpenLayers.Control.Zoom = OpenLayers.Class(OpenLayers.Control, {17 18 /**19 * APIProperty: zoomInText20 * {String}21 * Text for zoom-in link. Default is "+".22 */23 zoomInText: "+",24 /**25 * APIProperty: zoomInId26 * {String}27 * Instead of having the control create a zoom in link, you can provide 28 * the identifier for an anchor element already added to the document.29 * By default, an element with id "olZoomInLink" will be searched for30 * and used if it exists.31 */32 zoomInId: "olZoomInLink",33 /**34 * APIProperty: zoomOutText35 * {String}36 * Text for zoom-out link. Default is "\u2212".37 */38 zoomOutText: "\u2212",39 /**40 * APIProperty: zoomOutId41 * {String}42 * Instead of having the control create a zoom out link, you can provide 43 * the identifier for an anchor element already added to the document.44 * By default, an element with id "olZoomOutLink" will be searched for45 * and used if it exists.46 */47 zoomOutId: "olZoomOutLink",48 /**49 * Method: draw50 *51 * Returns:52 * {DOMElement} A reference to the DOMElement containing the zoom links.53 */54 draw: function() {55 var div = OpenLayers.Control.prototype.draw.apply(this),56 links = this.getOrCreateLinks(div),57 zoomIn = links.zoomIn,58 zoomOut = links.zoomOut,59 eventsInstance = this.map.events;60 61 if (zoomOut.parentNode !== div) {62 eventsInstance = this.events;63 eventsInstance.attachToElement(zoomOut.parentNode);64 }65 eventsInstance.register("buttonclick", this, this.onZoomClick);66 67 this.zoomInLink = zoomIn;68 this.zoomOutLink = zoomOut;69 return div;70 },71 72 /**73 * Method: getOrCreateLinks74 * 75 * Parameters:76 * el - {DOMElement}77 *78 * Return: 79 * {Object} Object with zoomIn and zoomOut properties referencing links.80 */81 getOrCreateLinks: function(el) {82 var zoomIn = document.getElementById(this.zoomInId),83 zoomOut = document.getElementById(this.zoomOutId);84 if (!zoomIn) {85 zoomIn = document.createElement("a");86 zoomIn.href = "#zoomIn";87 zoomIn.appendChild(document.createTextNode(this.zoomInText));88 zoomIn.className = "olControlZoomIn";89 el.appendChild(zoomIn);90 }91 OpenLayers.Element.addClass(zoomIn, "olButton");92 if (!zoomOut) {93 zoomOut = document.createElement("a");94 zoomOut.href = "#zoomOut";95 zoomOut.appendChild(document.createTextNode(this.zoomOutText));96 zoomOut.className = "olControlZoomOut";97 el.appendChild(zoomOut);98 }99 OpenLayers.Element.addClass(zoomOut, "olButton");100 return {101 zoomIn: zoomIn, zoomOut: zoomOut102 };103 },104 105 /**106 * Method: onZoomClick107 * Called when zoomin/out link is clicked.108 */109 onZoomClick: function(evt) {110 var button = evt.buttonElement;111 if (button === this.zoomInLink) {112 this.map.zoomIn();113 } else if (button === this.zoomOutLink) {114 this.map.zoomOut();115 }116 },117 /** 118 * Method: destroy119 * Clean up.120 */121 destroy: function() {122 if (this.map) {123 this.map.events.unregister("buttonclick", this, this.onZoomClick);124 }125 delete this.zoomInLink;126 delete this.zoomOutLink;127 OpenLayers.Control.prototype.destroy.apply(this);128 },129 CLASS_NAME: "OpenLayers.Control.Zoom"...
Control.Zoom.js
Source:Control.Zoom.js
...101 this.addControl(this.zoomControl);102 }103});104// @namespace Control.Zoom105// @factory L.control.zoom(options: Control.Zoom options)106// Creates a zoom control107L.control.zoom = function (options) {108 return new L.Control.Zoom(options);...
Zoom.js.uncompressed.js
Source:Zoom.js.uncompressed.js
1define("dojox/drawing/plugins/tools/Zoom", ["dojo/_base/lang", "../../util/oo", "../_Plugin", "../../manager/_registry"],2function(lang, oo, Plugin, registry){3 // zoomInc: Float4 // The amount of zoom that will occur upon each click.5 var zoomInc = Math.pow(2.0,0.25),6 // maxZoom: Number7 // The maximum the canvas can be zoomed in. 10 = 1000%8 maxZoom = 10,9 // minZoom: Float10 // The most the canvas can be zoomed out. .1 = 10%11 minZoom = 0.1,12 // zoomFactor: [readonly] Float13 // The current zoom amount14 zoomFactor = 1, 15 dt;16 17 if(!lang.getObject('dojox.drawing.plugins.tools')){18 lang.setObject('dojox.drawing.plugins.tools', {});19 }20 dt = dojox.drawing.plugins.tools;21 22 dt.ZoomIn = oo.declare(23 // summary:24 Plugin,25 function(options){26 27 },28 {29 type:"dojox.drawing.plugins.tools.ZoomIn",30 onZoomIn: function(){31 // summary:32 // Handles zoom in.33 zoomFactor *= zoomInc;34 zoomFactor = Math.min(zoomFactor, maxZoom);35 this.canvas.setZoom(zoomFactor);36 this.mouse.setZoom(zoomFactor);37 },38 onClick: function(){39 this.onZoomIn();40 }41 }42 );43 44 dt.Zoom100 = oo.declare(45 // summary:46 Plugin,47 function(options){48 49 },50 {51 type:"dojox.drawing.plugins.tools.Zoom100",52 onZoom100: function(){53 // summary:54 // Zooms to 100%55 zoomFactor = 1;56 this.canvas.setZoom(zoomFactor);57 this.mouse.setZoom(zoomFactor);58 },59 onClick: function(){60 this.onZoom100();61 }62 }63 );64 65 dt.ZoomOut = oo.declare(66 // summary:67 Plugin,68 function(options){69 70 },71 {72 type:"dojox.drawing.plugins.tools.ZoomOut",73 onZoomOut: function(){74 // summary:75 // Handles zoom out.76 zoomFactor /= zoomInc;77 zoomFactor = Math.max(zoomFactor, minZoom);78 this.canvas.setZoom(zoomFactor);79 this.mouse.setZoom(zoomFactor);80 },81 onClick: function(){82 this.onZoomOut();83 }84 }85 );86 87 dt.ZoomIn.setup = {88 name:"dojox.drawing.plugins.tools.ZoomIn",89 tooltip:"Zoom In"90 };91 registry.register(dt.ZoomIn.setup, "plugin");92 93 dt.Zoom100.setup = {94 name:"dojox.drawing.plugins.tools.Zoom100",95 tooltip:"Zoom to 100%"96 };97 registry.register(dt.Zoom100.setup, "plugin");98 99 dt.ZoomOut.setup = {100 name:"dojox.drawing.plugins.tools.ZoomOut",101 tooltip:"Zoom In"102 };103 registry.register(dt.ZoomOut.setup, "plugin");104 return dt;...
Using AI Code Generation
1$(document).ready(function() {2 $("a.zoom").click(function() {3 var editor = $(this).closest(".best_in_place").data("bestInPlaceEditor");4 editor.zoom();5 });6});7BestInPlaceEditor.prototype.zoom = function() {8 var editor = this;9 editor.activateForm();10 editor.$input.addClass("zoom");11 editor.$input.focus();12};13.zoom {14 width: 100%;15 height: 100%;16 font-size: 20px;17 padding: 20px;18}19.zoom {20 width: 100%;21 height: 100%;22 font-size: 20px;23 padding: 20px;24}25.zoom {26 width: 100%;27 height: 100%;28 font-size: 20px;29 padding: 20px;30}31.zoom {32 width: 100%;33 height: 100%;34 font-size: 20px;35 padding: 20px;36}37.zoom {38 width: 100%;39 height: 100%;40 font-size: 20px;41 padding: 20px;42}43.zoom {44 width: 100%;45 height: 100%;46 font-size: 20px;47 padding: 20px;48}49.zoom {50 width: 100%;51 height: 100%;52 font-size: 20px;53 padding: 20px;54}55.zoom {56 width: 100%;57 height: 100%;58 font-size: 20px;59 padding: 20px;60}61.zoom {62 width: 100%;
Using AI Code Generation
1$(document).ready(function() {2 jQuery(".best_in_place").best_in_place();3});4(function($) {5 $.fn.best_in_place_jquery_ui_editor = function(options) {6 var initialize_editor, success;7 options = $.extend({}, $.fn.best_in_place_jquery_ui_editor.defaults, options);8 success = function(form) {9 var activate_input, activate_textarea, activate_select, activate_checkbox, activate_datepicker, display_element, input_element, input_element_type, new_value, new_values, new_text, new_texts, new_html, new_htmls, new_htmls_select, new_htmls_checkbox, new_htmls_datepicker, cancel_editor, save_editor, handle_keypress;10 display_element = this;11 input_element = form.find(":input");12 input_element_type = input_element.attr('type');13 new_value = input_element.val();14 new_text = input_element.find("option:selected").text();15 new_html = input_element.html();16 new_values = input_element.val() || [];17 new_texts = input_element.find("option:selected").text() || [];18 new_htmls = input_element.html() || [];19 new_htmls_select = input_element.find("option:selected").html() || [];20 new_htmls_checkbox = input_element.find("option:checked").html() || [];21 new_htmls_datepicker = input_element.find(".ui-datepicker").html() || [];22 cancel_editor = function() {23 if (options.cancel) {24 options.cancel(form, input_element);25 }26 display_element.revert();27 return display_element.activate();28 };29 save_editor = function() {30 if (options.save) {31 options.save(form, input_element);32 }33 display_element.abort();34 display_element.activate();35 return display_element.update_in_place_editor(new_value, new_text, new_html, new_values, new_texts, new_htmls, new_htmls_select, new_htmls_checkbox, new_htmls_datepicker);36 };37 handle_keypress = function(e) {38 if (e.keyCode === 27) {39 cancel_editor();40 }41 if (e.keyCode === 13) {42 save_editor();43 }44 return true;45 };46 activate_input = function() {
Using AI Code Generation
1var request = require('request');2request(url, function (error, response, body) {3 if (!error && response.statusCode == 200) {4 }5})6var request = require('request');7request(url, function (error, response, body) {8 if (!error && response.statusCode == 200) {9 }10})11var request = require('request');12request(url, function (error, response, body) {13 if (!error && response.statusCode == 200) {14 }15})16var request = require('request');17request(url, function (error, response, body) {18 if (!error && response.statusCode == 200) {19 }20})21var request = require('request');22request(url, function (error, response, body) {
Using AI Code Generation
1$("a#mylink").click(function() {2 $("span#myspan").data("bestInPlaceEditor").zoom();3});4$("a#mylink").click(function() {5 $("span#myspan").data("bestInPlaceEditor").zoom();6});7$("a#mylink").click(function() {8 $("span#myspan").data("bestInPlaceEditor").zoom();9});10$("a#mylink").click(function() {11 $("span#myspan").data("bestInPlaceEditor").zoom();12});13$("a#mylink").click(function() {14 $("span#myspan").data("bestInPlaceEditor").zoom();15});16$("a#mylink").click(function() {17 $("span#myspan").data("bestInPlaceEditor").zoom();18});19$("a#mylink").click(function() {20 $("span#myspan").data("bestInPlaceEditor").zoom();21});22$("a#mylink").click(function() {23 $("span#myspan").data("bestInPlaceEditor").zoom();24});25$("a#mylink").click(function() {26 $("span#myspan").data("bestInPlaceEditor").zoom();27});28$("a#mylink").click(function() {29 $("span#myspan").data("bestInPlaceEditor").zoom();30});31$("a#mylink").click(function() {32 $("span#myspan").data("bestInPlaceEditor").zoom();33});
Using AI Code Generation
1var BestBuyAPI = require('bestbuyjs');2var bb = new BestBuyAPI('YOUR_API_KEY_HERE');3bb.zoom('products', 1234, function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10### BestBuyAPI(apiKey, [options])11var BestBuyAPI = require('bestbuyjs');12var bb = new BestBuyAPI('YOUR_API_KEY_HERE', {13});14### BestBuyAPI#list(resource, [options], callback)
Using AI Code Generation
1var zoom = BestZoom.zoom(100, 200, 300, 400, 500, 600);2console.log(zoom);3var bestZoom = BestZoom.getBestZoom(100, 200, 300, 400, 500, 600);4console.log(bestZoom);5var bestZoom = BestZoom.getBestZoom(100, 200, 300, 400, 500, 600);6console.log(bestZoom);7var bestZoom = BestZoom.getBestZoom(100, 200, 300, 400, 500, 600);8console.log(bestZoom);
Using AI Code Generation
1var request = require('request');2request(url, function(err, response, body) {3 if (!err && response.statusCode == 200) {4 var parsedData = JSON.parse(body);5 console.log(parsedData.products[0].name);6 }7});8var request = require('request');9request(url, function(err, response, body) {10 if (!err && response.statusCode == 200) {11 var parsedData = JSON.parse(body);12 console.log(parsedData.products[0].name);13 }14});15var request = require('request');16request(url, function(err, response, body) {17 if (!err && response.statusCode == 200) {18 var parsedData = JSON.parse(body);19 console.log(parsedData.products[0].name);20 }21});22var request = require('request');23request(url, function(err, response, body) {24 if (!err && response.statusCode == 200) {25 var parsedData = JSON.parse(body);26 console.log(parsedData.products[0].name);27 }28});29var request = require('request');
Using AI Code Generation
1var request = require('request');2var fs = require('fs');3var apiKey = fs.readFileSync('./apiKey.txt','utf8');4apiKey = apiKey.replace(/\s/g,'');5var product = process.argv[2];6var zip = process.argv[3];7var options = {8 headers: {9 }10};11function callback(error, response, body) {12 if (!error && response.statusCode == 200) {13 var info = JSON.parse(body);14 console.log(info.stores[0].storeId);15 console.log(info.stores[0].name);16 }17}18request(options, callback);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!