Commit fdcdcbce458b56756f425e7b696090abf4ee4b20
1 parent
541bd234
update...
Showing
8 changed files
with
775 additions
and
60 deletions
src/main/resources/static/real_control_v2/assets/plugins/uikit-2.27.1/components/lightbox.js
0 → 100644
| 1 | +/*! UIkit 2.25.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ | |
| 2 | +(function(addon) { | |
| 3 | + | |
| 4 | + var component; | |
| 5 | + | |
| 6 | + if (window.UIkit) { | |
| 7 | + component = addon(UIkit); | |
| 8 | + } | |
| 9 | + | |
| 10 | + if (typeof define == "function" && define.amd) { // AMD | |
| 11 | + define("uikit-lightbox", ["uikit"], function(){ | |
| 12 | + return component || addon(UIkit); | |
| 13 | + }); | |
| 14 | + } | |
| 15 | + | |
| 16 | +})(function(UI){ | |
| 17 | + | |
| 18 | + "use strict"; | |
| 19 | + | |
| 20 | + var modal, cache = {}; | |
| 21 | + | |
| 22 | + UI.component('lightbox', { | |
| 23 | + | |
| 24 | + defaults: { | |
| 25 | + "group" : false, | |
| 26 | + "duration" : 400, | |
| 27 | + "keyboard" : true | |
| 28 | + }, | |
| 29 | + | |
| 30 | + index : 0, | |
| 31 | + items : false, | |
| 32 | + | |
| 33 | + boot: function() { | |
| 34 | + | |
| 35 | + UI.$html.on('click', '[data-uk-lightbox]', function(e){ | |
| 36 | + | |
| 37 | + e.preventDefault(); | |
| 38 | + | |
| 39 | + var link = UI.$(this); | |
| 40 | + | |
| 41 | + if (!link.data("lightbox")) { | |
| 42 | + | |
| 43 | + UI.lightbox(link, UI.Utils.options(link.attr("data-uk-lightbox"))); | |
| 44 | + } | |
| 45 | + | |
| 46 | + link.data("lightbox").show(link); | |
| 47 | + }); | |
| 48 | + | |
| 49 | + // keyboard navigation | |
| 50 | + UI.$doc.on('keyup', function(e) { | |
| 51 | + | |
| 52 | + if (modal && modal.is(':visible') && modal.lightbox.options.keyboard) { | |
| 53 | + | |
| 54 | + e.preventDefault(); | |
| 55 | + | |
| 56 | + switch(e.keyCode) { | |
| 57 | + case 37: | |
| 58 | + modal.lightbox.previous(); | |
| 59 | + break; | |
| 60 | + case 39: | |
| 61 | + modal.lightbox.next(); | |
| 62 | + break; | |
| 63 | + } | |
| 64 | + } | |
| 65 | + }); | |
| 66 | + }, | |
| 67 | + | |
| 68 | + init: function() { | |
| 69 | + | |
| 70 | + var siblings = []; | |
| 71 | + | |
| 72 | + this.index = 0; | |
| 73 | + this.siblings = []; | |
| 74 | + | |
| 75 | + if (this.element && this.element.length) { | |
| 76 | + | |
| 77 | + var domSiblings = this.options.group ? UI.$([ | |
| 78 | + '[data-uk-lightbox*="'+this.options.group+'"]', | |
| 79 | + "[data-uk-lightbox*='"+this.options.group+"']" | |
| 80 | + ].join(',')) : this.element; | |
| 81 | + | |
| 82 | + domSiblings.each(function() { | |
| 83 | + | |
| 84 | + var ele = UI.$(this); | |
| 85 | + | |
| 86 | + siblings.push({ | |
| 87 | + 'source': ele.attr('href'), | |
| 88 | + 'title' : ele.attr('data-title') || ele.attr('title'), | |
| 89 | + 'type' : ele.attr("data-lightbox-type") || 'auto', | |
| 90 | + 'link' : ele | |
| 91 | + }); | |
| 92 | + }); | |
| 93 | + | |
| 94 | + this.index = domSiblings.index(this.element); | |
| 95 | + this.siblings = siblings; | |
| 96 | + | |
| 97 | + } else if (this.options.group && this.options.group.length) { | |
| 98 | + this.siblings = this.options.group; | |
| 99 | + } | |
| 100 | + | |
| 101 | + this.trigger('lightbox-init', [this]); | |
| 102 | + }, | |
| 103 | + | |
| 104 | + show: function(index) { | |
| 105 | + | |
| 106 | + this.modal = getModal(this); | |
| 107 | + | |
| 108 | + // stop previous animation | |
| 109 | + this.modal.dialog.stop(); | |
| 110 | + this.modal.content.stop(); | |
| 111 | + | |
| 112 | + var $this = this, promise = UI.$.Deferred(), data, item; | |
| 113 | + | |
| 114 | + index = index || 0; | |
| 115 | + | |
| 116 | + // index is a jQuery object or DOM element | |
| 117 | + if (typeof(index) == 'object') { | |
| 118 | + | |
| 119 | + this.siblings.forEach(function(s, idx){ | |
| 120 | + | |
| 121 | + if (index[0] === s.link[0]) { | |
| 122 | + index = idx; | |
| 123 | + } | |
| 124 | + }); | |
| 125 | + } | |
| 126 | + | |
| 127 | + // fix index if needed | |
| 128 | + if ( index < 0 ) { | |
| 129 | + index = this.siblings.length - index; | |
| 130 | + } else if (!this.siblings[index]) { | |
| 131 | + index = 0; | |
| 132 | + } | |
| 133 | + | |
| 134 | + item = this.siblings[index]; | |
| 135 | + | |
| 136 | + data = { | |
| 137 | + "lightbox" : $this, | |
| 138 | + "source" : item.source, | |
| 139 | + "type" : item.type, | |
| 140 | + "index" : index, | |
| 141 | + "promise" : promise, | |
| 142 | + "title" : item.title, | |
| 143 | + "item" : item, | |
| 144 | + "meta" : { | |
| 145 | + "content" : '', | |
| 146 | + "width" : null, | |
| 147 | + "height" : null | |
| 148 | + } | |
| 149 | + }; | |
| 150 | + | |
| 151 | + this.index = index; | |
| 152 | + | |
| 153 | + this.modal.content.empty(); | |
| 154 | + | |
| 155 | + if (!this.modal.is(':visible')) { | |
| 156 | + this.modal.content.css({width:'', height:''}).empty(); | |
| 157 | + this.modal.modal.show(); | |
| 158 | + } | |
| 159 | + | |
| 160 | + this.modal.loader.removeClass('uk-hidden'); | |
| 161 | + | |
| 162 | + promise.promise().done(function() { | |
| 163 | + | |
| 164 | + $this.data = data; | |
| 165 | + $this.fitSize(data); | |
| 166 | + | |
| 167 | + }).fail(function(){ | |
| 168 | + | |
| 169 | + data.meta.content = '<div class="uk-position-cover uk-flex uk-flex-middle uk-flex-center"><strong>Loading resource failed!</strong></div>'; | |
| 170 | + data.meta.width = 400; | |
| 171 | + data.meta.height = 300; | |
| 172 | + | |
| 173 | + $this.data = data; | |
| 174 | + $this.fitSize(data); | |
| 175 | + }); | |
| 176 | + | |
| 177 | + $this.trigger('showitem.uk.lightbox', [data]); | |
| 178 | + }, | |
| 179 | + | |
| 180 | + fitSize: function() { | |
| 181 | + | |
| 182 | + var $this = this, | |
| 183 | + data = this.data, | |
| 184 | + pad = this.modal.dialog.outerWidth() - this.modal.dialog.width(), | |
| 185 | + dpadTop = parseInt(this.modal.dialog.css('margin-top'), 10), | |
| 186 | + dpadBot = parseInt(this.modal.dialog.css('margin-bottom'), 10), | |
| 187 | + dpad = dpadTop + dpadBot, | |
| 188 | + content = data.meta.content, | |
| 189 | + duration = $this.options.duration; | |
| 190 | + | |
| 191 | + if (this.siblings.length > 1) { | |
| 192 | + | |
| 193 | + content = [ | |
| 194 | + content, | |
| 195 | + '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous uk-hidden-touch" data-lightbox-previous></a>', | |
| 196 | + '<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next uk-hidden-touch" data-lightbox-next></a>' | |
| 197 | + ].join(''); | |
| 198 | + } | |
| 199 | + | |
| 200 | + // calculate width | |
| 201 | + var tmp = UI.$('<div> </div>').css({ | |
| 202 | + 'opacity' : 0, | |
| 203 | + 'position' : 'absolute', | |
| 204 | + 'top' : 0, | |
| 205 | + 'left' : 0, | |
| 206 | + 'width' : '100%', | |
| 207 | + 'max-width' : $this.modal.dialog.css('max-width'), | |
| 208 | + 'padding' : $this.modal.dialog.css('padding'), | |
| 209 | + 'margin' : $this.modal.dialog.css('margin') | |
| 210 | + }), maxwidth, maxheight, w = data.meta.width, h = data.meta.height; | |
| 211 | + | |
| 212 | + tmp.appendTo('body').width(); | |
| 213 | + | |
| 214 | + maxwidth = tmp.width(); | |
| 215 | + maxheight = window.innerHeight - dpad; | |
| 216 | + | |
| 217 | + tmp.remove(); | |
| 218 | + | |
| 219 | + this.modal.dialog.find('.uk-modal-caption').remove(); | |
| 220 | + | |
| 221 | + if (data.title) { | |
| 222 | + this.modal.dialog.append('<div class="uk-modal-caption">'+data.title+'</div>'); | |
| 223 | + maxheight -= this.modal.dialog.find('.uk-modal-caption').outerHeight(); | |
| 224 | + } | |
| 225 | + | |
| 226 | + if (maxwidth < data.meta.width) { | |
| 227 | + | |
| 228 | + h = Math.floor( h * (maxwidth / w) ); | |
| 229 | + w = maxwidth; | |
| 230 | + } | |
| 231 | + | |
| 232 | + if (maxheight < h) { | |
| 233 | + | |
| 234 | + h = Math.floor(maxheight); | |
| 235 | + w = Math.ceil(data.meta.width * (maxheight/data.meta.height)); | |
| 236 | + } | |
| 237 | + | |
| 238 | + this.modal.content.css('opacity', 0).width(w).html(content); | |
| 239 | + | |
| 240 | + if (data.type == 'iframe') { | |
| 241 | + this.modal.content.find('iframe:first').height(h); | |
| 242 | + } | |
| 243 | + | |
| 244 | + var dh = h + pad, | |
| 245 | + t = Math.floor(window.innerHeight/2 - dh/2) - dpad; | |
| 246 | + | |
| 247 | + if (t < 0) { t = 0; } | |
| 248 | + | |
| 249 | + this.modal.closer.addClass('uk-hidden'); | |
| 250 | + | |
| 251 | + if ($this.modal.data('mwidth') == w && $this.modal.data('mheight') == h) { | |
| 252 | + duration = 0; | |
| 253 | + } | |
| 254 | + | |
| 255 | + this.modal.dialog.animate({width: w + pad, height: h + pad, top: t }, duration, 'swing', function() { | |
| 256 | + $this.modal.loader.addClass('uk-hidden'); | |
| 257 | + $this.modal.content.css({width:''}).animate({'opacity': 1}, function() { | |
| 258 | + $this.modal.closer.removeClass('uk-hidden'); | |
| 259 | + }); | |
| 260 | + | |
| 261 | + $this.modal.data({'mwidth': w, 'mheight': h}); | |
| 262 | + }); | |
| 263 | + }, | |
| 264 | + | |
| 265 | + next: function() { | |
| 266 | + this.show(this.siblings[(this.index+1)] ? (this.index+1) : 0); | |
| 267 | + }, | |
| 268 | + | |
| 269 | + previous: function() { | |
| 270 | + this.show(this.siblings[(this.index-1)] ? (this.index-1) : this.siblings.length-1); | |
| 271 | + } | |
| 272 | + }); | |
| 273 | + | |
| 274 | + | |
| 275 | + // Plugins | |
| 276 | + | |
| 277 | + UI.plugin('lightbox', 'image', { | |
| 278 | + | |
| 279 | + init: function(lightbox) { | |
| 280 | + | |
| 281 | + lightbox.on("showitem.uk.lightbox", function(e, data){ | |
| 282 | + | |
| 283 | + if (data.type == 'image' || data.source && data.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)) { | |
| 284 | + | |
| 285 | + var resolve = function(source, width, height) { | |
| 286 | + | |
| 287 | + data.meta = { | |
| 288 | + "content" : '<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">', | |
| 289 | + "width" : width, | |
| 290 | + "height" : height | |
| 291 | + }; | |
| 292 | + | |
| 293 | + data.type = 'image'; | |
| 294 | + | |
| 295 | + data.promise.resolve(); | |
| 296 | + }; | |
| 297 | + | |
| 298 | + if (!cache[data.source]) { | |
| 299 | + | |
| 300 | + var img = new Image(); | |
| 301 | + | |
| 302 | + img.onerror = function(){ | |
| 303 | + data.promise.reject('Loading image failed'); | |
| 304 | + }; | |
| 305 | + | |
| 306 | + img.onload = function(){ | |
| 307 | + cache[data.source] = {width: img.width, height: img.height}; | |
| 308 | + resolve(data.source, cache[data.source].width, cache[data.source].height); | |
| 309 | + }; | |
| 310 | + | |
| 311 | + img.src = data.source; | |
| 312 | + | |
| 313 | + } else { | |
| 314 | + resolve(data.source, cache[data.source].width, cache[data.source].height); | |
| 315 | + } | |
| 316 | + } | |
| 317 | + }); | |
| 318 | + } | |
| 319 | + }); | |
| 320 | + | |
| 321 | + UI.plugin("lightbox", "youtube", { | |
| 322 | + | |
| 323 | + init: function(lightbox) { | |
| 324 | + | |
| 325 | + var youtubeRegExp = /(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/, | |
| 326 | + youtubeRegExpShort = /youtu\.be\/(.*)/; | |
| 327 | + | |
| 328 | + | |
| 329 | + lightbox.on("showitem.uk.lightbox", function(e, data){ | |
| 330 | + | |
| 331 | + var id, matches, resolve = function(id, width, height) { | |
| 332 | + | |
| 333 | + data.meta = { | |
| 334 | + 'content': '<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"></iframe>', | |
| 335 | + 'width': width, | |
| 336 | + 'height': height | |
| 337 | + }; | |
| 338 | + | |
| 339 | + data.type = 'iframe'; | |
| 340 | + | |
| 341 | + data.promise.resolve(); | |
| 342 | + }; | |
| 343 | + | |
| 344 | + if (matches = data.source.match(youtubeRegExp)) { | |
| 345 | + id = matches[2]; | |
| 346 | + } | |
| 347 | + | |
| 348 | + if (matches = data.source.match(youtubeRegExpShort)) { | |
| 349 | + id = matches[1]; | |
| 350 | + } | |
| 351 | + | |
| 352 | + if (id) { | |
| 353 | + | |
| 354 | + if(!cache[id]) { | |
| 355 | + | |
| 356 | + var img = new Image(), lowres = false; | |
| 357 | + | |
| 358 | + img.onerror = function(){ | |
| 359 | + cache[id] = {width:640, height:320}; | |
| 360 | + resolve(id, cache[id].width, cache[id].height); | |
| 361 | + }; | |
| 362 | + | |
| 363 | + img.onload = function(){ | |
| 364 | + //youtube default 404 thumb, fall back to lowres | |
| 365 | + if (img.width == 120 && img.height == 90) { | |
| 366 | + if (!lowres) { | |
| 367 | + lowres = true; | |
| 368 | + img.src = '//img.youtube.com/vi/' + id + '/0.jpg'; | |
| 369 | + } else { | |
| 370 | + cache[id] = {width: 640, height: 320}; | |
| 371 | + resolve(id, cache[id].width, cache[id].height); | |
| 372 | + } | |
| 373 | + } else { | |
| 374 | + cache[id] = {width: img.width, height: img.height}; | |
| 375 | + resolve(id, img.width, img.height); | |
| 376 | + } | |
| 377 | + }; | |
| 378 | + | |
| 379 | + img.src = '//img.youtube.com/vi/'+id+'/maxresdefault.jpg'; | |
| 380 | + | |
| 381 | + } else { | |
| 382 | + resolve(id, cache[id].width, cache[id].height); | |
| 383 | + } | |
| 384 | + | |
| 385 | + e.stopImmediatePropagation(); | |
| 386 | + } | |
| 387 | + }); | |
| 388 | + } | |
| 389 | + }); | |
| 390 | + | |
| 391 | + | |
| 392 | + UI.plugin("lightbox", "vimeo", { | |
| 393 | + | |
| 394 | + init: function(lightbox) { | |
| 395 | + | |
| 396 | + var regex = /(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/, matches; | |
| 397 | + | |
| 398 | + | |
| 399 | + lightbox.on("showitem.uk.lightbox", function(e, data){ | |
| 400 | + | |
| 401 | + var id, resolve = function(id, width, height) { | |
| 402 | + | |
| 403 | + data.meta = { | |
| 404 | + 'content': '<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"></iframe>', | |
| 405 | + 'width': width, | |
| 406 | + 'height': height | |
| 407 | + }; | |
| 408 | + | |
| 409 | + data.type = 'iframe'; | |
| 410 | + | |
| 411 | + data.promise.resolve(); | |
| 412 | + }; | |
| 413 | + | |
| 414 | + if (matches = data.source.match(regex)) { | |
| 415 | + | |
| 416 | + id = matches[2]; | |
| 417 | + | |
| 418 | + if(!cache[id]) { | |
| 419 | + | |
| 420 | + UI.$.ajax({ | |
| 421 | + type : 'GET', | |
| 422 | + url : 'http://vimeo.com/api/oembed.json?url=' + encodeURI(data.source), | |
| 423 | + jsonp : 'callback', | |
| 424 | + dataType : 'jsonp', | |
| 425 | + success : function(data) { | |
| 426 | + cache[id] = {width:data.width, height:data.height}; | |
| 427 | + resolve(id, cache[id].width, cache[id].height); | |
| 428 | + } | |
| 429 | + }); | |
| 430 | + | |
| 431 | + } else { | |
| 432 | + resolve(id, cache[id].width, cache[id].height); | |
| 433 | + } | |
| 434 | + | |
| 435 | + e.stopImmediatePropagation(); | |
| 436 | + } | |
| 437 | + }); | |
| 438 | + } | |
| 439 | + }); | |
| 440 | + | |
| 441 | + UI.plugin("lightbox", "video", { | |
| 442 | + | |
| 443 | + init: function(lightbox) { | |
| 444 | + | |
| 445 | + lightbox.on("showitem.uk.lightbox", function(e, data){ | |
| 446 | + | |
| 447 | + | |
| 448 | + var resolve = function(source, width, height) { | |
| 449 | + | |
| 450 | + data.meta = { | |
| 451 | + 'content': '<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>', | |
| 452 | + 'width': width, | |
| 453 | + 'height': height | |
| 454 | + }; | |
| 455 | + | |
| 456 | + data.type = 'video'; | |
| 457 | + | |
| 458 | + data.promise.resolve(); | |
| 459 | + }; | |
| 460 | + | |
| 461 | + if (data.type == 'video' || data.source.match(/\.(mp4|webm|ogv)$/i)) { | |
| 462 | + | |
| 463 | + if (!cache[data.source]) { | |
| 464 | + | |
| 465 | + var vid = UI.$('<video style="position:fixed;visibility:hidden;top:-10000px;"></video>').attr('src', data.source).appendTo('body'); | |
| 466 | + | |
| 467 | + var idle = setInterval(function() { | |
| 468 | + | |
| 469 | + if (vid[0].videoWidth) { | |
| 470 | + clearInterval(idle); | |
| 471 | + cache[data.source] = {width: vid[0].videoWidth, height: vid[0].videoHeight}; | |
| 472 | + resolve(data.source, cache[data.source].width, cache[data.source].height); | |
| 473 | + vid.remove(); | |
| 474 | + } | |
| 475 | + | |
| 476 | + }, 20); | |
| 477 | + | |
| 478 | + } else { | |
| 479 | + resolve(data.source, cache[data.source].width, cache[data.source].height); | |
| 480 | + } | |
| 481 | + } | |
| 482 | + }); | |
| 483 | + } | |
| 484 | + }); | |
| 485 | + | |
| 486 | + | |
| 487 | + function getModal(lightbox) { | |
| 488 | + | |
| 489 | + if (modal) { | |
| 490 | + modal.lightbox = lightbox; | |
| 491 | + return modal; | |
| 492 | + } | |
| 493 | + | |
| 494 | + // init lightbox container | |
| 495 | + modal = UI.$([ | |
| 496 | + '<div class="uk-modal">', | |
| 497 | + '<div class="uk-modal-dialog uk-modal-dialog-lightbox uk-slidenav-position" style="margin-left:auto;margin-right:auto;width:200px;height:200px;top:'+Math.abs(window.innerHeight/2 - 200)+'px;">', | |
| 498 | + '<a href="#" class="uk-modal-close uk-close uk-close-alt"></a>', | |
| 499 | + '<div class="uk-lightbox-content"></div>', | |
| 500 | + '<div class="uk-modal-spinner uk-hidden"></div>', | |
| 501 | + '</div>', | |
| 502 | + '</div>' | |
| 503 | + ].join('')).appendTo('body'); | |
| 504 | + | |
| 505 | + modal.dialog = modal.find('.uk-modal-dialog:first'); | |
| 506 | + modal.content = modal.find('.uk-lightbox-content:first'); | |
| 507 | + modal.loader = modal.find('.uk-modal-spinner:first'); | |
| 508 | + modal.closer = modal.find('.uk-close.uk-close-alt'); | |
| 509 | + modal.modal = UI.modal(modal, {modal:false, bgclose: false}); | |
| 510 | + | |
| 511 | + // next / previous | |
| 512 | +/* modal.on("swipeRight swipeLeft", function(e) { | |
| 513 | + modal.lightbox[e.type=='swipeLeft' ? 'next':'previous'](); | |
| 514 | + }).on("click", "[data-lightbox-previous], [data-lightbox-next]", function(e){ | |
| 515 | + e.preventDefault(); | |
| 516 | + modal.lightbox[UI.$(this).is('[data-lightbox-next]') ? 'next':'previous'](); | |
| 517 | + });*/ | |
| 518 | + | |
| 519 | + // destroy content on modal hide | |
| 520 | + modal.on("hide.uk.modal", function(e) { | |
| 521 | + modal.content.html(''); | |
| 522 | + }); | |
| 523 | + | |
| 524 | + UI.$win.on('load resize orientationchange', UI.Utils.debounce(function(e){ | |
| 525 | + if (modal.is(':visible') && !UI.Utils.isFullscreen()) modal.lightbox.fitSize(); | |
| 526 | + }.bind(this), 100)); | |
| 527 | + | |
| 528 | + modal.lightbox = lightbox; | |
| 529 | + | |
| 530 | + return modal; | |
| 531 | + } | |
| 532 | + | |
| 533 | + UI.lightbox.create = function(items, options) { | |
| 534 | + | |
| 535 | + if (!items) return; | |
| 536 | + | |
| 537 | + var group = [], o; | |
| 538 | + | |
| 539 | + items.forEach(function(item) { | |
| 540 | + | |
| 541 | + group.push(UI.$.extend({ | |
| 542 | + 'source' : '', | |
| 543 | + 'title' : '', | |
| 544 | + 'type' : 'auto', | |
| 545 | + 'link' : false | |
| 546 | + }, (typeof(item) == 'string' ? {'source': item} : item))); | |
| 547 | + }); | |
| 548 | + | |
| 549 | + o = UI.lightbox(UI.$.extend({}, options, {'group':group})); | |
| 550 | + | |
| 551 | + return o; | |
| 552 | + }; | |
| 553 | + | |
| 554 | + return UI.lightbox; | |
| 555 | +}); | ... | ... |
src/main/resources/static/real_control_v2/assets/plugins/uikit-2.27.1/components/lightbox.min.js
| 1 | -/* UIkit 2.27.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ | |
| 2 | -!function(i){var t;window.UIkit&&(t=i(UIkit)),"function"==typeof define&&define.amd&&define("uikit-lightbox",["uikit"],function(){return t||i(UIkit)})}(function(i){"use strict";function t(t){if(e)return e.lightbox=t,e;e=i.$(['<div class="uk-modal">','<div class="uk-modal-dialog uk-modal-dialog-lightbox uk-slidenav-position" style="margin-left:auto;margin-right:auto;width:200px;height:200px;top:'+Math.abs(window.innerHeight/2-200)+'px;">','<a href="#" class="uk-modal-close uk-close uk-close-alt"></a>','<div class="uk-lightbox-content"></div>','<div class="uk-modal-spinner uk-hidden"></div>',"</div>","</div>"].join("")).appendTo("body"),e.dialog=e.find(".uk-modal-dialog:first"),e.content=e.find(".uk-lightbox-content:first"),e.loader=e.find(".uk-modal-spinner:first"),e.closer=e.find(".uk-close.uk-close-alt"),e.modal=i.modal(e,{modal:!1}),e.on("swipeRight swipeLeft",function(i){e.lightbox["swipeLeft"==i.type?"next":"previous"]()}).on("click","[data-lightbox-previous], [data-lightbox-next]",function(t){t.preventDefault(),e.lightbox[i.$(this).is("[data-lightbox-next]")?"next":"previous"]()}),e.on("hide.uk.modal",function(){e.content.html("")});var o={w:window.innerWidth,h:window.innerHeight};return i.$win.on("load resize orientationchange",i.Utils.debounce(function(){o.w!==window.innerWidth&&e.is(":visible")&&!i.Utils.isFullscreen()&&e.lightbox.fitSize(),o={w:window.innerWidth,h:window.innerHeight}},100)),e.lightbox=t,e}var e,o={};return i.component("lightbox",{defaults:{allowfullscreen:!0,duration:400,group:!1,keyboard:!0},index:0,items:!1,boot:function(){i.$html.on("click","[data-uk-lightbox]",function(t){t.preventDefault();var e=i.$(this);e.data("lightbox")||i.lightbox(e,i.Utils.options(e.attr("data-uk-lightbox"))),e.data("lightbox").show(e)}),i.$doc.on("keyup",function(i){if(e&&e.is(":visible")&&e.lightbox.options.keyboard)switch(i.preventDefault(),i.keyCode){case 37:e.lightbox.previous();break;case 39:e.lightbox.next()}})},init:function(){var t=[];if(this.index=0,this.siblings=[],this.element&&this.element.length){var e=this.options.group?i.$(['[data-uk-lightbox*="'+this.options.group+'"]',"[data-uk-lightbox*='"+this.options.group+"']"].join(",")):this.element;e.each(function(){var e=i.$(this);t.push({source:e.attr("href"),title:e.attr("data-title")||e.attr("title"),type:e.attr("data-lightbox-type")||"auto",link:e})}),this.index=e.index(this.element),this.siblings=t}else this.options.group&&this.options.group.length&&(this.siblings=this.options.group);this.trigger("lightbox-init",[this])},show:function(e){this.modal=t(this),this.modal.dialog.stop(),this.modal.content.stop();var o,n,s=this,h=i.$.Deferred();e=e||0,"object"==typeof e&&this.siblings.forEach(function(i,t){e[0]===i.link[0]&&(e=t)}),0>e?e=this.siblings.length-e:this.siblings[e]||(e=0),n=this.siblings[e],o={lightbox:s,source:n.source,type:n.type,index:e,promise:h,title:n.title,item:n,meta:{content:"",width:null,height:null}},this.index=e,this.modal.content.empty(),this.modal.is(":visible")||(this.modal.content.css({width:"",height:""}).empty(),this.modal.modal.show()),this.modal.loader.removeClass("uk-hidden"),h.promise().done(function(){s.data=o,s.fitSize(o)}).fail(function(){o.meta.content='<div class="uk-position-cover uk-flex uk-flex-middle uk-flex-center"><strong>Loading resource failed!</strong></div>',o.meta.width=400,o.meta.height=300,s.data=o,s.fitSize(o)}),s.trigger("showitem.uk.lightbox",[o])},fitSize:function(){var t=this,e=this.data,o=this.modal.dialog.outerWidth()-this.modal.dialog.width(),n=parseInt(this.modal.dialog.css("margin-top"),10),s=parseInt(this.modal.dialog.css("margin-bottom"),10),h=n+s,a=e.meta.content,l=t.options.duration;this.siblings.length>1&&(a=[a,'<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous uk-hidden-touch" data-lightbox-previous></a>','<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next uk-hidden-touch" data-lightbox-next></a>'].join(""));var d,r,u=i.$("<div> </div>").css({opacity:0,position:"absolute",top:0,left:0,width:"100%","max-width":t.modal.dialog.css("max-width"),padding:t.modal.dialog.css("padding"),margin:t.modal.dialog.css("margin")}),c=e.meta.width,g=e.meta.height;u.appendTo("body").width(),d=u.width(),r=window.innerHeight-h,u.remove(),this.modal.dialog.find(".uk-modal-caption").remove(),e.title&&(this.modal.dialog.append('<div class="uk-modal-caption">'+e.title+"</div>"),r-=this.modal.dialog.find(".uk-modal-caption").outerHeight()),d<e.meta.width&&(g=Math.floor(g*(d/c)),c=d),g>r&&(g=Math.floor(r),c=Math.ceil(e.meta.width*(r/e.meta.height))),this.modal.content.css("opacity",0).width(c).html(a),"iframe"==e.type&&this.modal.content.find("iframe:first").height(g);var m=g+o,p=Math.floor(window.innerHeight/2-m/2)-h;0>p&&(p=0),this.modal.closer.addClass("uk-hidden"),t.modal.data("mwidth")==c&&t.modal.data("mheight")==g&&(l=0),this.modal.dialog.animate({width:c+o,height:g+o,top:p},l,"swing",function(){t.modal.loader.addClass("uk-hidden"),t.modal.content.css({width:""}).animate({opacity:1},function(){t.modal.closer.removeClass("uk-hidden")}),t.modal.data({mwidth:c,mheight:g})})},next:function(){this.show(this.siblings[this.index+1]?this.index+1:0)},previous:function(){this.show(this.siblings[this.index-1]?this.index-1:this.siblings.length-1)}}),i.plugin("lightbox","image",{init:function(i){i.on("showitem.uk.lightbox",function(i,t){if("image"==t.type||t.source&&t.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)){var e=function(i,e,o){t.meta={content:'<img class="uk-responsive-width" width="'+e+'" height="'+o+'" src ="'+i+'">',width:e,height:o},t.type="image",t.promise.resolve()};if(o[t.source])e(t.source,o[t.source].width,o[t.source].height);else{var n=new Image;n.onerror=function(){t.promise.reject("Loading image failed")},n.onload=function(){o[t.source]={width:n.width,height:n.height},e(t.source,o[t.source].width,o[t.source].height)},n.src=t.source}}})}}),i.plugin("lightbox","youtube",{init:function(i){var t=/(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,n=/youtu\.be\/(.*)/;i.on("showitem.uk.lightbox",function(i,s){var h,a,l=function(i,t,o){s.meta={content:'<iframe src="//www.youtube.com/embed/'+i+'" width="'+t+'" height="'+o+'" style="max-width:100%;"'+(e.lightbox.options.allowfullscreen?" allowfullscreen":"")+"></iframe>",width:t,height:o},s.type="iframe",s.promise.resolve()};if((a=s.source.match(t))&&(h=a[2]),(a=s.source.match(n))&&(h=a[1]),h){if(o[h])l(h,o[h].width,o[h].height);else{var d=new Image,r=!1;d.onerror=function(){o[h]={width:640,height:320},l(h,o[h].width,o[h].height)},d.onload=function(){120==d.width&&90==d.height?r?(o[h]={width:640,height:320},l(h,o[h].width,o[h].height)):(r=!0,d.src="//img.youtube.com/vi/"+h+"/0.jpg"):(o[h]={width:d.width,height:d.height},l(h,d.width,d.height))},d.src="//img.youtube.com/vi/"+h+"/maxresdefault.jpg"}i.stopImmediatePropagation()}})}}),i.plugin("lightbox","vimeo",{init:function(t){var n,s=/(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/;t.on("showitem.uk.lightbox",function(t,h){var a,l=function(i,t,o){h.meta={content:'<iframe src="//player.vimeo.com/video/'+i+'" width="'+t+'" height="'+o+'" style="width:100%;box-sizing:border-box;"'+(e.lightbox.options.allowfullscreen?" allowfullscreen":"")+"></iframe>",width:t,height:o},h.type="iframe",h.promise.resolve()};(n=h.source.match(s))&&(a=n[2],o[a]?l(a,o[a].width,o[a].height):i.$.ajax({type:"GET",url:"//vimeo.com/api/oembed.json?url="+encodeURI(h.source),jsonp:"callback",dataType:"jsonp",success:function(i){o[a]={width:i.width,height:i.height},l(a,o[a].width,o[a].height)}}),t.stopImmediatePropagation())})}}),i.plugin("lightbox","video",{init:function(t){t.on("showitem.uk.lightbox",function(t,e){var n=function(i,t,o){e.meta={content:'<video class="uk-responsive-width" src="'+i+'" width="'+t+'" height="'+o+'" controls></video>',width:t,height:o},e.type="video",e.promise.resolve()};if("video"==e.type||e.source.match(/\.(mp4|webm|ogv)$/i))if(o[e.source])n(e.source,o[e.source].width,o[e.source].height);else var s=i.$('<video style="position:fixed;visibility:hidden;top:-10000px;"></video>').attr("src",e.source).appendTo("body"),h=setInterval(function(){s[0].videoWidth&&(clearInterval(h),o[e.source]={width:s[0].videoWidth,height:s[0].videoHeight},n(e.source,o[e.source].width,o[e.source].height),s.remove())},20)})}}),UIkit.plugin("lightbox","iframe",{init:function(i){i.on("showitem.uk.lightbox",function(t,o){var n=function(i,t,n){o.meta={content:'<iframe class="uk-responsive-width" src="'+i+'" width="'+t+'" height="'+n+'"'+(e.lightbox.options.allowfullscreen?" allowfullscreen":"")+"></iframe>",width:t,height:n},o.type="iframe",o.promise.resolve()};("iframe"===o.type||o.source.match(/\.(html|php)$/))&&n(o.source,i.options.width||800,i.options.height||600)})}}),i.lightbox.create=function(t,e){if(t){var o,n=[];return t.forEach(function(t){n.push(i.$.extend({source:"",title:"",type:"auto",link:!1},"string"==typeof t?{source:t}:t))}),o=i.lightbox(i.$.extend({},e,{group:n}))}},i.lightbox}); | |
| 3 | 1 | \ No newline at end of file |
| 2 | +(function(addon){var component;if(window.UIkit){component=addon(UIkit)}if(typeof define=="function"&&define.amd){define("uikit-lightbox",["uikit"],function(){return component||addon(UIkit)})}})(function(UI){"use strict";var modal,cache={};UI.component('lightbox',{defaults:{"group":false,"duration":400,"keyboard":true},index:0,items:false,boot:function(){UI.$html.on('click','[data-uk-lightbox]',function(e){e.preventDefault();var link=UI.$(this);if(!link.data("lightbox")){UI.lightbox(link,UI.Utils.options(link.attr("data-uk-lightbox")))}link.data("lightbox").show(link)});UI.$doc.on('keyup',function(e){if(modal&&modal.is(':visible')&&modal.lightbox.options.keyboard){e.preventDefault();switch(e.keyCode){case 37:modal.lightbox.previous();break;case 39:modal.lightbox.next();break}}})},init:function(){var siblings=[];this.index=0;this.siblings=[];if(this.element&&this.element.length){var domSiblings=this.options.group?UI.$(['[data-uk-lightbox*="'+this.options.group+'"]',"[data-uk-lightbox*='"+this.options.group+"']"].join(',')):this.element;domSiblings.each(function(){var ele=UI.$(this);siblings.push({'source':ele.attr('href'),'title':ele.attr('data-title')||ele.attr('title'),'type':ele.attr("data-lightbox-type")||'auto','link':ele})});this.index=domSiblings.index(this.element);this.siblings=siblings}else if(this.options.group&&this.options.group.length){this.siblings=this.options.group}this.trigger('lightbox-init',[this])},show:function(index){this.modal=getModal(this);this.modal.dialog.stop();this.modal.content.stop();var $this=this,promise=UI.$.Deferred(),data,item;index=index||0;if(typeof(index)=='object'){this.siblings.forEach(function(s,idx){if(index[0]===s.link[0]){index=idx}})}if(index<0){index=this.siblings.length-index}else if(!this.siblings[index]){index=0}item=this.siblings[index];data={"lightbox":$this,"source":item.source,"type":item.type,"index":index,"promise":promise,"title":item.title,"item":item,"meta":{"content":'',"width":null,"height":null}};this.index=index;this.modal.content.empty();if(!this.modal.is(':visible')){this.modal.content.css({width:'',height:''}).empty();this.modal.modal.show()}this.modal.loader.removeClass('uk-hidden');promise.promise().done(function(){$this.data=data;$this.fitSize(data)}).fail(function(){data.meta.content='<div class="uk-position-cover uk-flex uk-flex-middle uk-flex-center"><strong>Loading resource failed!</strong></div>';data.meta.width=400;data.meta.height=300;$this.data=data;$this.fitSize(data)});$this.trigger('showitem.uk.lightbox',[data])},fitSize:function(){var $this=this,data=this.data,pad=this.modal.dialog.outerWidth()-this.modal.dialog.width(),dpadTop=parseInt(this.modal.dialog.css('margin-top'),10),dpadBot=parseInt(this.modal.dialog.css('margin-bottom'),10),dpad=dpadTop+dpadBot,content=data.meta.content,duration=$this.options.duration;if(this.siblings.length>1){content=[content,'<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-previous uk-hidden-touch" data-lightbox-previous></a>','<a href="#" class="uk-slidenav uk-slidenav-contrast uk-slidenav-next uk-hidden-touch" data-lightbox-next></a>'].join('')}var tmp=UI.$('<div> </div>').css({'opacity':0,'position':'absolute','top':0,'left':0,'width':'100%','max-width':$this.modal.dialog.css('max-width'),'padding':$this.modal.dialog.css('padding'),'margin':$this.modal.dialog.css('margin')}),maxwidth,maxheight,w=data.meta.width,h=data.meta.height;tmp.appendTo('body').width();maxwidth=tmp.width();maxheight=window.innerHeight-dpad;tmp.remove();this.modal.dialog.find('.uk-modal-caption').remove();if(data.title){this.modal.dialog.append('<div class="uk-modal-caption">'+data.title+'</div>');maxheight-=this.modal.dialog.find('.uk-modal-caption').outerHeight()}if(maxwidth<data.meta.width){h=Math.floor(h*(maxwidth/w));w=maxwidth}if(maxheight<h){h=Math.floor(maxheight);w=Math.ceil(data.meta.width*(maxheight/data.meta.height))}this.modal.content.css('opacity',0).width(w).html(content);if(data.type=='iframe'){this.modal.content.find('iframe:first').height(h)}var dh=h+pad,t=Math.floor(window.innerHeight/2-dh/2)-dpad;if(t<0){t=0}this.modal.closer.addClass('uk-hidden');if($this.modal.data('mwidth')==w&&$this.modal.data('mheight')==h){duration=0}this.modal.dialog.animate({width:w+pad,height:h+pad,top:t},duration,'swing',function(){$this.modal.loader.addClass('uk-hidden');$this.modal.content.css({width:''}).animate({'opacity':1},function(){$this.modal.closer.removeClass('uk-hidden')});$this.modal.data({'mwidth':w,'mheight':h})})},next:function(){this.show(this.siblings[(this.index+1)]?(this.index+1):0)},previous:function(){this.show(this.siblings[(this.index-1)]?(this.index-1):this.siblings.length-1)}});UI.plugin('lightbox','image',{init:function(lightbox){lightbox.on("showitem.uk.lightbox",function(e,data){if(data.type=='image'||data.source&&data.source.match(/\.(jpg|jpeg|png|gif|svg)$/i)){var resolve=function(source,width,height){data.meta={"content":'<img class="uk-responsive-width" width="'+width+'" height="'+height+'" src ="'+source+'">',"width":width,"height":height};data.type='image';data.promise.resolve()};if(!cache[data.source]){var img=new Image();img.onerror=function(){data.promise.reject('Loading image failed')};img.onload=function(){cache[data.source]={width:img.width,height:img.height};resolve(data.source,cache[data.source].width,cache[data.source].height)};img.src=data.source}else{resolve(data.source,cache[data.source].width,cache[data.source].height)}}})}});UI.plugin("lightbox","youtube",{init:function(lightbox){var youtubeRegExp=/(\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)&?(.*)/,youtubeRegExpShort=/youtu\.be\/(.*)/;lightbox.on("showitem.uk.lightbox",function(e,data){var id,matches,resolve=function(id,width,height){data.meta={'content':'<iframe src="//www.youtube.com/embed/'+id+'" width="'+width+'" height="'+height+'" style="max-width:100%;"></iframe>','width':width,'height':height};data.type='iframe';data.promise.resolve()};if(matches=data.source.match(youtubeRegExp)){id=matches[2]}if(matches=data.source.match(youtubeRegExpShort)){id=matches[1]}if(id){if(!cache[id]){var img=new Image(),lowres=false;img.onerror=function(){cache[id]={width:640,height:320};resolve(id,cache[id].width,cache[id].height)};img.onload=function(){if(img.width==120&&img.height==90){if(!lowres){lowres=true;img.src='//img.youtube.com/vi/'+id+'/0.jpg'}else{cache[id]={width:640,height:320};resolve(id,cache[id].width,cache[id].height)}}else{cache[id]={width:img.width,height:img.height};resolve(id,img.width,img.height)}};img.src='//img.youtube.com/vi/'+id+'/maxresdefault.jpg'}else{resolve(id,cache[id].width,cache[id].height)}e.stopImmediatePropagation()}})}});UI.plugin("lightbox","vimeo",{init:function(lightbox){var regex=/(\/\/.*?)vimeo\.[a-z]+\/([0-9]+).*?/,matches;lightbox.on("showitem.uk.lightbox",function(e,data){var id,resolve=function(id,width,height){data.meta={'content':'<iframe src="//player.vimeo.com/video/'+id+'" width="'+width+'" height="'+height+'" style="width:100%;box-sizing:border-box;"></iframe>','width':width,'height':height};data.type='iframe';data.promise.resolve()};if(matches=data.source.match(regex)){id=matches[2];if(!cache[id]){UI.$.ajax({type:'GET',url:'http://vimeo.com/api/oembed.json?url='+encodeURI(data.source),jsonp:'callback',dataType:'jsonp',success:function(data){cache[id]={width:data.width,height:data.height};resolve(id,cache[id].width,cache[id].height)}})}else{resolve(id,cache[id].width,cache[id].height)}e.stopImmediatePropagation()}})}});UI.plugin("lightbox","video",{init:function(lightbox){lightbox.on("showitem.uk.lightbox",function(e,data){var resolve=function(source,width,height){data.meta={'content':'<video class="uk-responsive-width" src="'+source+'" width="'+width+'" height="'+height+'" controls></video>','width':width,'height':height};data.type='video';data.promise.resolve()};if(data.type=='video'||data.source.match(/\.(mp4|webm|ogv)$/i)){if(!cache[data.source]){var vid=UI.$('<video style="position:fixed;visibility:hidden;top:-10000px;"></video>').attr('src',data.source).appendTo('body');var idle=setInterval(function(){if(vid[0].videoWidth){clearInterval(idle);cache[data.source]={width:vid[0].videoWidth,height:vid[0].videoHeight};resolve(data.source,cache[data.source].width,cache[data.source].height);vid.remove()}},20)}else{resolve(data.source,cache[data.source].width,cache[data.source].height)}}})}});function getModal(lightbox){if(modal){modal.lightbox=lightbox;return modal}modal=UI.$(['<div class="uk-modal">','<div class="uk-modal-dialog uk-modal-dialog-lightbox uk-slidenav-position" style="margin-left:auto;margin-right:auto;width:200px;height:200px;top:'+Math.abs(window.innerHeight/2-200)+'px;">','<a href="#" class="uk-modal-close uk-close uk-close-alt"></a>','<div class="uk-lightbox-content"></div>','<div class="uk-modal-spinner uk-hidden"></div>','</div>','</div>'].join('')).appendTo('body');modal.dialog=modal.find('.uk-modal-dialog:first');modal.content=modal.find('.uk-lightbox-content:first');modal.loader=modal.find('.uk-modal-spinner:first');modal.closer=modal.find('.uk-close.uk-close-alt');modal.modal=UI.modal(modal,{modal:false,bgclose:false});modal.on("hide.uk.modal",function(e){modal.content.html('')});UI.$win.on('load resize orientationchange',UI.Utils.debounce(function(e){if(modal.is(':visible')&&!UI.Utils.isFullscreen())modal.lightbox.fitSize()}.bind(this),100));modal.lightbox=lightbox;return modal}UI.lightbox.create=function(items,options){if(!items)return;var group=[],o;items.forEach(function(item){group.push(UI.$.extend({'source':'','title':'','type':'auto','link':false},(typeof(item)=='string'?{'source':item}:item)))});o=UI.lightbox(UI.$.extend({},options,{'group':group}));return o};return UI.lightbox}); | |
| 4 | 3 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/css/north.css
| ... | ... | @@ -500,4 +500,38 @@ span.sm-red{ |
| 500 | 500 | span.sm-grey{ |
| 501 | 501 | font-size: 12px; |
| 502 | 502 | color: grey; |
| 503 | +} | |
| 504 | + | |
| 505 | +.voip_call_info_panel{ | |
| 506 | + width: 258px; | |
| 507 | + background: #ffffff; | |
| 508 | + display: inline-block; | |
| 509 | + vertical-align: bottom; | |
| 510 | + border-left: 1px solid #d8cece; | |
| 511 | +} | |
| 512 | + | |
| 513 | +.uk-lightbox-content>img{ | |
| 514 | + display: inline-block; | |
| 515 | +} | |
| 516 | + | |
| 517 | +.voip_call_info_panel form{ | |
| 518 | + padding: 15px 15px 0 15px; | |
| 519 | + vertical-align: bottom; | |
| 520 | +} | |
| 521 | + | |
| 522 | +.voip_call_info_panel .uk-form-horizontal .uk-form-label{ | |
| 523 | + width: 70px; | |
| 524 | +} | |
| 525 | + | |
| 526 | +.voip_call_info_panel .uk-form-horizontal .uk-form-controls{ | |
| 527 | + margin-left: 72px; | |
| 528 | +} | |
| 529 | + | |
| 530 | +.voip_call_info_panel .state_txt{ | |
| 531 | + text-align: center; | |
| 532 | +} | |
| 533 | + | |
| 534 | +.voip_call_info_panel ._title{ | |
| 535 | + padding: 15px; | |
| 536 | + background: #e6e6e6; | |
| 503 | 537 | } |
| 504 | 538 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/fragments/north/nav/safeDriving.html
| ... | ... | @@ -79,7 +79,7 @@ |
| 79 | 79 | <a class="image_link" href="{{sd.url}}.gif" data-uk-lightbox="{group:'gif_group2'}" title="{{sd.title}}">查看</a> |
| 80 | 80 | </td> |
| 81 | 81 | <td> |
| 82 | - <a data-type="{{sd.yczltype}}" class="show_vedio_modal">DVR</a> | |
| 82 | + <a data-type="{{sd.yczltype}}" class="show_vedio_modal" style="color: grey">DVR</a> | |
| 83 | 83 | </td> |
| 84 | 84 | </tr> |
| 85 | 85 | {{/each}} |
| ... | ... | @@ -136,7 +136,11 @@ |
| 136 | 136 | url = stm.format('YYYYMMDD')+'/'+p+'/'+p; |
| 137 | 137 | this.url = gb_safe_driv.urlPath + url; |
| 138 | 138 | //title |
| 139 | - this.title = this.clzbh+' '+stm.format('HH时mm分ss秒')+' '+this.yczlText; | |
| 139 | + var call_btn_html = '<button class="uk-button uk-button-mini uk-button-primary" ' + | |
| 140 | + 'id="m_voip_call_btn_001" ' + | |
| 141 | + 'type="button" ' + | |
| 142 | + 'data-nbbm="'+this.clzbh+'">打电话</button>'; | |
| 143 | + this.title = this.clzbh+' '+stm.format('HH时mm分ss秒')+' '+this.yczlText + ' ' + call_btn_html; | |
| 140 | 144 | }); |
| 141 | 145 | |
| 142 | 146 | var bodyHtml = template('all-safe_dring-table-temp', { | ... | ... |
src/main/resources/static/real_control_v2/js/modal_extend.js
src/main/resources/static/real_control_v2/js/safe_driv/call_phone.js
| 1 | 1 | var gb_call_phone = function () { |
| 2 | + /* | |
| 2 | 3 | |
| 3 | 4 | var basePath = "http://180.168.57.114:4244"; |
| 4 | 5 | var wsUri = "ws://180.168.57.114:21892/"; |
| ... | ... | @@ -113,5 +114,109 @@ var gb_call_phone = function () { |
| 113 | 114 | getNbbm2tel: function () { |
| 114 | 115 | return nbbm2tel; |
| 115 | 116 | } |
| 117 | + }*/ | |
| 118 | + | |
| 119 | + /** | |
| 120 | + * 0 已挂断 | |
| 121 | + * 1 通话中 | |
| 122 | + * @type {number} | |
| 123 | + */ | |
| 124 | + var phoneStatus=0; | |
| 125 | + | |
| 126 | + var _nbbm; | |
| 127 | + var simNo; | |
| 128 | + var agentID; | |
| 129 | + var dn; | |
| 130 | + var wrap = '.voip_call_info_panel'; | |
| 131 | + var init = function (nbbm) { | |
| 132 | + _nbbm = nbbm; | |
| 133 | + agentID = $('[name=agentID]', wrap).val(); | |
| 134 | + dn = $('[name=dn]', wrap).val(); | |
| 135 | + | |
| 136 | + var $stateBtnTxt = $('.state_txt>button', wrap); | |
| 137 | + var $simInput = $('[name=simNo]', wrap); | |
| 138 | + | |
| 139 | + var eq = EventProxy.create('pluginInit', 'getSimNo', function () { | |
| 140 | + simNo = ('9' + simNo); | |
| 141 | + $simInput.val(simNo); | |
| 142 | + if(!simNo){ | |
| 143 | + $stateBtnTxt.text('获取SIM卡号失败!'); | |
| 144 | + return; | |
| 145 | + } | |
| 146 | + $stateBtnTxt.text('正在拨号...') | |
| 147 | + .attr('disabled', 'disabled'); | |
| 148 | + //拨号 | |
| 149 | + $.PhonePluginFun.Dialing("913052310315"); | |
| 150 | + }); | |
| 151 | + | |
| 152 | + //初始化插件 | |
| 153 | + pluginInit(agentID, dn, function () { | |
| 154 | + eq.emitLater('pluginInit'); | |
| 155 | + }); | |
| 156 | + | |
| 157 | + //获取SIM | |
| 158 | + $.PhonePluginFun.GetSimCardNo(nbbm, function (no) { | |
| 159 | + simNo = no; | |
| 160 | + eq.emitLater('getSimNo'); | |
| 161 | + }); | |
| 162 | + }; | |
| 163 | + | |
| 164 | + var talking = function () { | |
| 165 | + console.log('talking'); | |
| 166 | + phoneStatus = 1; | |
| 167 | + | |
| 168 | + setTimeout(function () { | |
| 169 | + var $stateBtnTxt = $('.state_txt>button', wrap); | |
| 170 | + $stateBtnTxt.text('已接通,点击挂断!') | |
| 171 | + .removeClass('uk-button-primary') | |
| 172 | + .addClass('uk-button-danger') | |
| 173 | + .removeAttr('disabled') | |
| 174 | + .off('click') | |
| 175 | + .one('click', function () { | |
| 176 | + _hangup(); | |
| 177 | + _hold(); | |
| 178 | + }); | |
| 179 | + }, 1000); | |
| 180 | + }; | |
| 181 | + | |
| 182 | + var _hold = function () { | |
| 183 | + console.log('_hold'); | |
| 184 | + phoneStatus = 0; | |
| 185 | + | |
| 186 | + var $stateBtnTxt = $('.state_txt>button', wrap); | |
| 187 | + $stateBtnTxt.text('点击拨号') | |
| 188 | + .removeClass('uk-button-danger') | |
| 189 | + .addClass('uk-button-primary') | |
| 190 | + .off('click') | |
| 191 | + .one('click', function () { | |
| 192 | + init(_nbbm); | |
| 193 | + }); | |
| 194 | + }; | |
| 195 | + | |
| 196 | + var pluginInit = function (agentID, dn, cb) { | |
| 197 | + var options = { | |
| 198 | + AgentID: agentID, | |
| 199 | + DN: dn, | |
| 200 | + /*接通事件*/ | |
| 201 | + OnTalking: talking, | |
| 202 | + /*挂机事件*/ | |
| 203 | + OnHold: _hold | |
| 204 | + }; | |
| 205 | + $.PhonePluginFun.init(options); | |
| 206 | + cb && cb(); | |
| 207 | + }; | |
| 208 | + | |
| 209 | + var _hangup = function () { | |
| 210 | + if(phoneStatus==0) | |
| 211 | + return; | |
| 212 | + console.log('hangup...'); | |
| 213 | + $.CallCenterPublicFun.Hangup(); | |
| 214 | + $.CallCenterPublicFun.LoginOff(); | |
| 215 | + phoneStatus = 0; | |
| 216 | + } | |
| 217 | + | |
| 218 | + return { | |
| 219 | + init: init, | |
| 220 | + hangup: _hangup | |
| 116 | 221 | } |
| 117 | 222 | }(); |
| 118 | 223 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/js/safe_driv/safeDriv.js
| ... | ... | @@ -20,11 +20,6 @@ var gb_safe_driv = (function () { |
| 20 | 20 | var max = 5; |
| 21 | 21 | |
| 22 | 22 | var pop = function (sd) { |
| 23 | - /*//只有admin用户能收到 | |
| 24 | - var user = gb_northToolbar.user(); | |
| 25 | - if (!user || user.userName.indexOf('admin') == -1) | |
| 26 | - return;*/ | |
| 27 | - | |
| 28 | 23 | //时间格式化 |
| 29 | 24 | var stm = moment(sd.ts); |
| 30 | 25 | sd.timeStr = stm.format('HH时mm分ss秒'); |
| ... | ... | @@ -43,29 +38,22 @@ var gb_safe_driv = (function () { |
| 43 | 38 | $wrap.append(htmlStr); |
| 44 | 39 | }; |
| 45 | 40 | |
| 46 | -/* var vedioModal = '<div id="ssspVedioModal" class="uk-modal ct_move_modal">' + | |
| 47 | - '<div class="uk-modal-dialog uk-modal-dialog-large">' + | |
| 48 | - '<button type="button" class="uk-modal-close uk-close"></button>' + | |
| 49 | - '<div class="uk-modal-header"> <h2>实时视频</h2> </div> '+ | |
| 50 | - '<p class="loading"><i class="uk-icon-spinner uk-icon-spin"></i> 载入资源...</p><iframe id="vedioIframe" src="http://222.66.0.204:8910/transport_server/dvr_monitor1.jsp?deviceId=229L0650&channel=^^channel^^"></iframe>' + | |
| 51 | - '</div>' + | |
| 52 | - '</div>';*/ | |
| 53 | - | |
| 54 | - var phoneModal = '<div id="callPhoneModal" class="uk-modal ct_move_modal">' + | |
| 55 | - '<div class="uk-modal-dialog">' + | |
| 56 | - '<button type="button" class="uk-modal-close uk-close"></button>' + | |
| 57 | - '<div class="uk-modal-header"> <h2>打电话</h2> </div> '+ | |
| 58 | - '<p class="loading"><i class="uk-icon-spinner uk-icon-spin"></i> 载入资源...</p><iframe style="width: 100%;height: 280px;" id="phoneIframe" src="/real_control_v2/js/safe_driv/CallCenterPluginDemo.html"></iframe>' + | |
| 59 | - '</div>' + | |
| 60 | - '</div>'; | |
| 41 | + | |
| 61 | 42 | |
| 62 | 43 | $wrap.on('click', '.safe_driv_pop', function () { |
| 63 | - var title = $(this).data('title');// + ' <button data-nbbm="'+$(this).data('nbbm')+'" class="uk-button uk-button-mini uk-button-primary" id="openPhoneModalBtn" type="button">打电话</button>'; | |
| 44 | + var nbbm = $(this).data('nbbm'); | |
| 45 | + var call_btn_html = '<button class="uk-button uk-button-mini uk-button-primary" ' + | |
| 46 | + 'id="m_voip_call_btn_001" ' + | |
| 47 | + 'type="button" ' + | |
| 48 | + 'data-nbbm="'+nbbm+'">打电话</button>'; | |
| 49 | + | |
| 50 | + var title = $(this).data('title') + ' ' + call_btn_html; | |
| 64 | 51 | var url = $(this).data('url'); |
| 65 | 52 | $(this).remove(); |
| 53 | + | |
| 66 | 54 | var lightbox = UIkit.lightbox.create([ |
| 67 | 55 | {title: title, 'source': url} |
| 68 | - ]); | |
| 56 | + ], {keyboard: false}); | |
| 69 | 57 | |
| 70 | 58 | lightbox.show(); |
| 71 | 59 | }); |
| ... | ... | @@ -80,7 +68,7 @@ var gb_safe_driv = (function () { |
| 80 | 68 | 'A6': 2, |
| 81 | 69 | 'A7': 2 |
| 82 | 70 | }; |
| 83 | - var showVedioModal = function (type) { | |
| 71 | +/* var showVedioModal = function (type) { | |
| 84 | 72 | var channel = channelMap[type]?channelMap[type]:1; |
| 85 | 73 | open_modal_dom(vedioModal.replace('^^channel^^', channel) ,{}, {modal: false}); |
| 86 | 74 | $('#ssspVedioModal #vedioIframe').on('load', function () { |
| ... | ... | @@ -90,14 +78,14 @@ var gb_safe_driv = (function () { |
| 90 | 78 | $('#ssspVedioModal p.loading').remove(); |
| 91 | 79 | }, 500); |
| 92 | 80 | }); |
| 93 | - }; | |
| 81 | + };*/ | |
| 94 | 82 | |
| 95 | - $(document).on('click', '#openVedioModalBtn', function () { | |
| 83 | +/* $(document).on('click', '#openVedioModalBtn', function () { | |
| 96 | 84 | showVedioModal($(this).data('type')); |
| 97 | - }); | |
| 85 | + });*/ | |
| 98 | 86 | |
| 99 | 87 | |
| 100 | - var showCallPhoneModal = function () { | |
| 88 | +/* var showCallPhoneModal = function () { | |
| 101 | 89 | open_modal_dom(phoneModal ,{}, {modal: false}); |
| 102 | 90 | $('#callPhoneModal #phoneIframe').on('load', function () { |
| 103 | 91 | var that = this; |
| ... | ... | @@ -116,38 +104,30 @@ var gb_safe_driv = (function () { |
| 116 | 104 | $('#callPhoneModal p.loading').remove(); |
| 117 | 105 | }, 700); |
| 118 | 106 | }); |
| 119 | - }; | |
| 107 | + };*/ | |
| 108 | + | |
| 109 | + $(document).on('click', '#m_voip_call_btn_001', function () { | |
| 110 | + //debugger | |
| 111 | + var $lb = $('.uk-modal-dialog-lightbox'); | |
| 112 | + var X = $lb.offset().top + $lb.height() - 240; | |
| 113 | + var Y = $lb.offset().left + $lb.width(); | |
| 114 | + | |
| 115 | + var nbbm = $(this).data('nbbm'); | |
| 120 | 116 | |
| 121 | - $(document).on('click', '#openPhoneModalBtn', function () { | |
| 122 | - var t = $(this).text(); | |
| 123 | - if(t == '挂断!'){ | |
| 124 | - gb_call_phone.hangup(); | |
| 125 | - $(this).text('打电话').removeClass('uk-button-danger'); | |
| 126 | - return; | |
| 127 | - } | |
| 128 | - else if(t == '打电话'){ | |
| 129 | - var nbbm = $(this).data('nbbm'); | |
| 130 | - var btn = this; | |
| 131 | - | |
| 132 | - $(btn).text('登录坐席..'); | |
| 133 | - gb_call_phone.call(nbbm, function () { | |
| 134 | - $(btn).text('拨号中..'); | |
| 135 | - }, function () { | |
| 136 | - $(btn).text('登录坐席失败'); | |
| 137 | - setTimeout(function () { | |
| 138 | - $(btn).text('打电话'); | |
| 139 | - }, 1200); | |
| 140 | - }, function () { | |
| 141 | - $(btn).text('挂断!').addClass('uk-button-danger'); | |
| 142 | - }); | |
| 143 | - } | |
| 117 | + var style = 'top: '+X+'px;left: '+Y+'px;height: '+$lb.height()+'px'; | |
| 118 | + var htmlStr = template('voip_call_info_panel-temp', {style: style, nbbm: nbbm}); | |
| 119 | + $lb.css('width', ($lb.width() + 260) + 'px'); | |
| 120 | + $('.uk-lightbox-content', $lb.parent()).append(htmlStr); | |
| 121 | + | |
| 122 | + $(this).remove(); | |
| 123 | + gb_call_phone.init(nbbm); | |
| 144 | 124 | }); |
| 145 | 125 | |
| 146 | 126 | |
| 147 | 127 | return { |
| 148 | 128 | pop: pop, |
| 149 | 129 | safeCode: codes, |
| 150 | - urlPath: path, | |
| 151 | - showVedioModal: showVedioModal | |
| 130 | + urlPath: path//, | |
| 131 | + //showVedioModal: showVedioModal | |
| 152 | 132 | } |
| 153 | 133 | })(); |
| 154 | 134 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/main.html
| ... | ... | @@ -237,10 +237,47 @@ |
| 237 | 237 | <script src="/real_control_v2/js/safe_driv/safeDriv.js" merge="custom_js"></script> |
| 238 | 238 | <!-- #### 安全驾驶 end ### --> |
| 239 | 239 | |
| 240 | -<!-- 打电话 | |
| 241 | -<script src="http://180.168.57.114:4244/Scripts/CallCenter.js" ></script> | |
| 240 | +<!-- 打电话 --> | |
| 241 | +<script src="http://114.80.178.12:9003/forward/voip/callCenterJs"></script> | |
| 242 | +<script src="http://114.80.178.12:9003/forward/voip/phonePluginJs"></script> | |
| 242 | 243 | <script src="/real_control_v2/js/safe_driv/call_phone.js" ></script> |
| 243 | ---> | |
| 244 | + | |
| 245 | +<script id="voip_call_info_panel-temp" type="text/html"> | |
| 246 | + <div class="voip_call_info_panel" style="{{style}}"> | |
| 247 | + <p class="_title">VOIP</p> | |
| 248 | + <form class="uk-form uk-form-horizontal"> | |
| 249 | + | |
| 250 | + <div class="uk-form-row"> | |
| 251 | + <label class="uk-form-label" >工号:</label> | |
| 252 | + <div class="uk-form-controls"> | |
| 253 | + <input type="text" name="agentID" value="1002" disabled> | |
| 254 | + </div> | |
| 255 | + </div> | |
| 256 | + <div class="uk-form-row"> | |
| 257 | + <label class="uk-form-label" ">分机号:</label> | |
| 258 | + <div class="uk-form-controls"> | |
| 259 | + <input type="text" name="dn" value="6014" > | |
| 260 | + </div> | |
| 261 | + </div> | |
| 262 | + <div class="uk-form-row"> | |
| 263 | + <label class="uk-form-label" >自编号:</label> | |
| 264 | + <div class="uk-form-controls"> | |
| 265 | + <input type="text" value="{{nbbm}}" disabled> | |
| 266 | + </div> | |
| 267 | + </div> | |
| 268 | + <div class="uk-form-row"> | |
| 269 | + <label class="uk-form-label" >SIM号:</label> | |
| 270 | + <div class="uk-form-controls"> | |
| 271 | + <input type="text" name="simNo" > | |
| 272 | + </div> | |
| 273 | + </div> | |
| 274 | + <hr> | |
| 275 | + <h4 class="state_txt"> | |
| 276 | + <button class="uk-button uk-button-large" type="button" disabled>获取SIM卡号...</button> | |
| 277 | + </h4> | |
| 278 | + </form> | |
| 279 | + </div> | |
| 280 | +</script> | |
| 244 | 281 | </body> |
| 245 | 282 | |
| 246 | 283 | </html> | ... | ... |