1/* 2 --- 3 name: SEATips 4 description: Class for creating nice tips that follow the mouse cursor when hovering an element. 5 6 Extends :Tips 7 8 requires: 9 - Core/Options 10 - Core/Events 11 - Core/Element.Event 12 - Core/Element.Style 13 - Core/Element.Dimensions 14 - /MooTools.More 15 16 provides: [Tips] 17 18 ... 19 */ 20window.addEvent('domready', function() { 21 en4.seaocore.isDomReady = true; 22 en4.seaocore.setDomElements(); 23}); 24 25(function() { 26 this.SEATips = new Class({ 27 Extends: Tips, 28 options: { 29 canHide: true 30 }, 31 hide: function(element) { 32 if (!this.options.canHide) 33 return; 34 if (!this.tip) 35 document.id(this); 36 this.fireEvent('hide', [this.tip, element]); 37 }, 38 position: function(event) { 39 if (!this.tip) 40 document.id(this); 41 var size = window.getSize(), scroll = window.getScroll(), 42 tip = { 43 x: this.tip.offsetWidth, 44 y: this.tip.offsetHeight 45 }, 46 props = { 47 x: 'left', 48 y: 'top' 49 }, 50 bounds = { 51 y: false, 52 x2: false, 53 y2: false, 54 x: false 55 }, 56 obj = {}; 57 for (var z in props) { 58 obj[props[z]] = event.page[z] + this.options.offset[z]; 59 if (obj[props[z]] < 0) 60 bounds[z] = true; 61 if ((event.page[z] - scroll[z]) > size[z] - this.options.windowPadding[z]) { 62 var extra = 1; 63 if (z == 'x') 64 extra = 51; 65 obj[props[z]] = event.page[z] - tip[z] + extra; 66 bounds[z + '2'] = true; 67 } 68 } 69 70 this.fireEvent('bound', bounds); 71 this.tip.setStyles(obj); 72 Smoothbox.bind(this.tip); 73 } 74 }); 75})(); 76 77en4.seaocore = { 78 headerElement : 'global_header', 79 footerElement : 'global_footer', 80 contentElement : 'global_content', 81 contentWrapperElement : 'global_wrapper', 82 83 isDomElementSet : false, 84 isDomReady : false, 85 86 setDomElements: function() { 87 this.headerElement = $('se-header') ? 'se-header' : 'global_header'; 88 this.footerElement = $('se-footer') ? 'se-footer' : 'global_footer'; 89 this.contentElement = $('se-content') ? 'se-content' : 'global_content'; 90 this.contentWrapperElement = $('se-main') ? 'se-main' : 'global_wrapper'; 91 this.isDomElementSet = true; 92 }, 93 94 setLayoutWidth: function(elementId, width) { 95 var layoutColumn = null; 96 if ($(elementId).getParent('.layout_left')) { 97 layoutColumn = $(elementId).getParent('.layout_left'); 98 } else if ($(elementId).getParent('.layout_right')) { 99 layoutColumn = $(elementId).getParent('.layout_right'); 100 } else if ($(elementId).getParent('.layout_middle')) { 101 layoutColumn = $(elementId).getParent('.layout_middle'); 102 } 103 if (layoutColumn) { 104 layoutColumn.setStyle('width', width); 105 } 106 $(elementId).destroy(); 107 }, 108 // load multiple assets and run callback function on successful loading 109 // Example - en4.seaocore.loadAssets([{type: 'javascript, src : 'script.js'} ], callback,{prependPath : en4.core.staticBaseUrl + 'required-path/'}); 110 loadAssets: function (assetsArray, callback, options) { 111 assetIndex = 0; 112 assetCount = assetsArray.length; 113 prependPath = options && options.prependPath ? options.prependPath : ''; 114 assetsArray.each(function(asset) { 115 Asset[asset.type](prependPath + asset.src, { 116 onLoad : function() { 117 if (++assetIndex == assetCount && typeof callback =='function') { 118 callback(); 119 } 120 } 121 }) 122 }) 123 }, 124 getDomElements: function(element) { 125 if( !this.isDomElementSet || !this.isDomReady) { 126 this.setDomElements(); 127 } 128 if( element == 'header' ) { 129 return this.headerElement; 130 } else if( element == 'footer' ) { 131 return this.footerElement; 132 } else if( element == 'content' ) { 133 return this.contentElement; 134 } else if( element == 'contentWrapper' ) { 135 return this.contentWrapperElement; 136 } 137 } 138}; 139/** 140 * likes 141 */ 142en4.seaocore.likes = { 143 like: function(type, id, show_bottom_post, comment_id) { 144 en4.core.request.send(new Request.JSON({ 145 url: en4.core.baseUrl + 'seaocore/comment/like', 146 data: { 147 format: 'json', 148 type: type, 149 id: id, 150 comment_id: 0, 151 show_bottom_post: show_bottom_post 152 }, 153 onSuccess: function(responseJSON) { 154 if ($type(responseJSON) == 'object' && $type(responseJSON.status)) { 155 if ($(type + '_' + id + 'like_link')) 156 $(type + '_' + id + 'like_link').style.display = "none"; 157 if ($(type + '_' + id + 'unlike_link')) 158 $(type + '_' + id + 'unlike_link').style.display = "inline-block"; 159 } 160 } 161 }), { 162 'element': $('comments' + '_' + type + '_' + id) 163 // "force":true 164 });
165 }, 166 unlike: function(type, id, show_bottom_post, comment_id) { 167 en4.core.request.send(new Request.JSON({ 168 url: en4.core.baseUrl + 'seaocore/comment/unlike', 169 data: { 170 format: 'json', 171 type: type, 172 id: id, 173 comment_id: comment_id, 174 show_bottom_post: show_bottom_post 175 }, 176 onSuccess: function(responseJSON) { 177 if ($type(responseJSON) == 'object' && $type(responseJSON.status)) { 178 if ($(type + '_' + id + 'unlike_link')) 179 $(type + '_' + id + 'unlike_link').style.display = "none"; 180 if ($(type + '_' + id + 'like_link')) 181 $(type + '_' + id + 'like_link').style.display = "inline-block"; 182 } 183 } 184 }), { 185 'element': $('comments' + '_' + type + '_' + id) 186 // "force":true 187 }); 188 } 189}; 190 191en4.seaocore.comments = { 192 loadComments: function(type, id, page, show_bottom_post) { 193 en4.core.request.send(new Request.HTML({ 194 url: en4.core.baseUrl + 'seaocore/comment/list', 195 data: { 196 format: 'html', 197 type: type, 198 id: id, 199 page: page, 200 show_bottom_post: show_bottom_post 201 } 202 }), { 203 'element': $('comments' + '_' + type + '_' + id), 204 "force": true 205 }); 206 }, 207 attachCreateComment: function(formElement, type, id, show_bottom_post) { 208 var bind = this; 209 if (show_bottom_post == 1) { 210 formElement.addEvent((Browser.Engine.trident || Browser.Engine.webkit) ? 'keydown' : 'keypress', function(event) { 211 if (event.shift && event.key == 'enter') { 212 } else if (event.key == 'enter') { 213 event.stop(); 214 var form_values = formElement.toQueryString(); 215 form_values += '&format=json'; 216 form_values += '&id=' + formElement.identity.value; 217 form_values += '&show_bottom_post=' + show_bottom_post; 218 formElement.style.display = "none"; 219 if ($("comment-form-loading-li_" + type + '_' + id)) 220 $("comment-form-loading-li_" + type + '_' + id).style.display = "block"; 221 en4.core.request.send(new Request.JSON({ 222 url: en4.core.baseUrl + 'seaocore/comment/create', 223 data: form_values, 224 type: type, 225 id: id, 226 show_bottom_post: show_bottom_post 227 }), { 228 'element': $('comments' + '_' + type + '_' + id), 229 "force": true 230 }); 231 232 } 233 }); 234 235 // add blur event 236 formElement.body.addEvent('blur', function() { 237 formElement.style.display = "none"; 238 if ($("comment-form-open-li_" + type + '_' + id)) 239 $("comment-form-open-li_" + type + '_' + id).style.display = "block"; 240 }); 241 } 242 formElement.addEvent('submit', function(event) { 243 event.stop(); 244 var form_values = formElement.toQueryString(); 245 form_values += '&format=json'; 246 form_values += '&id=' + formElement.identity.value; 247 form_values += '&show_bottom_post=' + show_bottom_post; 248 en4.core.request.send(new Request.JSON({ 249 url: en4.core.baseUrl + 'seaocore/comment/create', 250 data: form_values, 251 type: type, 252 id: id, 253 show_bottom_post: show_bottom_post 254 }), { 255 'element': $('comments' + '_' + type + '_' + id), 256 "force": true 257 }); 258 }) 259 }, 260 comment: function(type, id, body, show_bottom_post) { 261 en4.core.request.send(new Request.JSON({ 262 url: en4.core.baseUrl + 'seaocore/comment/create', 263 data: { 264 format: 'json', 265 type: type, 266 id: id, 267 body: body, 268 show_bottom_post: show_bottom_post 269 } 270 }), { 271 'element': $('comments' + '_' + type + '_' + id), 272 "force": true 273 }); 274 }, 275 like: function(type, id, show_bottom_post, comment_id) { 276 en4.core.request.send(new Request.JSON({ 277 url: en4.core.baseUrl + 'seaocore/comment/like', 278 data: { 279 format: 'json', 280 type: type, 281 id: id, 282 page: pageComment, 283 comment_id: comment_id, 284 show_bottom_post: show_bottom_post 285 }, 286 onSuccess: function(responseJSON) { 287 if ($type(responseJSON) == 'object' && $type(responseJSON.status)) { 288 if ($(type + '_' + id + 'like_link')) 289 $(type + '_' + id + 'like_link').style.display = "none"; 290 if ($(type + '_' + id + 'unlike_link')) 291 $(type + '_' + id + 'unlike_link').style.display = "inline-block"; 292 } 293 } 294 }), { 295 'element': $('comments' + '_' + type + '_' + id), 296 "force": true 297 });
298 }, 299 unlike: function(type, id, show_bottom_post, comment_id) { 300 en4.core.request.send(new Request.JSON({ 301 url: en4.core.baseUrl + 'seaocore/comment/unlike', 302 data: { 303 format: 'json', 304 type: type, 305 id: id, 306 page: pageComment, 307 comment_id: comment_id, 308 show_bottom_post: show_bottom_post 309 }, 310 onSuccess: function(responseJSON) { 311 if ($type(responseJSON) == 'object' && $type(responseJSON.status)) { 312 if ($(type + '_' + id + 'unlike_link')) 313 $(type + '_' + id + 'unlike_link').style.display = "none"; 314 if ($(type + '_' + id + 'like_link')) 315 $(type + '_' + id + 'like_link').style.display = "inline-block"; 316 } 317 } 318 }), { 319 'element': $('comments' + '_' + type + '_' + id), 320 "force": true 321 }); 322 }, 323 showLikes: function(type, id, show_bottom_post) { 324 en4.core.request.send(new Request.HTML({ 325 url: en4.core.baseUrl + 'seaocore/comment/list', 326 data: { 327 format: 'html', 328 type: type, 329 id: id, 330 viewAllLikes: true, 331 show_bottom_post: show_bottom_post 332 } 333 }), { 334 'element': $('comments' + '_' + type + '_' + id), 335 "force": true 336 }); 337 }, 338 deleteComment: function(type, id, comment_id) { 339 if (!confirm(en4.core.language.translate('Are you sure you want to delete this?'))) { 340 return; 341 } 342 (new Request.JSON({ 343 url: en4.core.baseUrl + 'seaocore/comment/delete', 344 data: { 345 format: 'json', 346 type: type, 347 id: id, 348 comment_id: comment_id 349 }, 350 onComplete: function() { 351 if ($('comment-' + comment_id)) { 352 $('comment-' + comment_id).destroy(); 353 } 354 try { 355 var commentCount = $$('.comments_options span')[0]; 356 var m = commentCount.get('html').match(/\d+/); 357 var newCount = (parseInt(m[0]) != 'NaN' && parseInt(m[0]) > 1 ? parseInt(m[0]) - 1 : 0); 358 commentCount.set('html', commentCount.get('html').replace(m[0], newCount)); 359 } catch (e) { 360 } 361 } 362 })).send(); 363 } 364}; 365 366en4.seaocore.facebook = { 367 runFacebookSdk: function() { 368 369 window.fbAsyncInit = function() { 370 FB.JSON.stringify = function(value) { 371 return JSON.encode(value); 372 }; 373 FB.init({ 374 appId: fbappid, 375 status: true, // check login status 376 cookie: true, // enable cookies to allow the server to access the session 377 xfbml: true // parse XFBML 378 }); 379 380 if (window.setFBContent) { 381 382 setFBContent(); 383 } 384 }; 385 (function() { 386 en4.seaocore.setDomElements(); 387 var catarea = $(en4.seaocore.footerElement); 388 if (catarea == null) { 389 catarea = $(en4.seaocore.contentElement); 390 } 391 if (catarea != null && (typeof $('fb-root') == 'undefined' || $('fb-root') == null)) { 392 var newdiv = document.createElement('div'); 393 newdiv.id = 'fb-root'; 394 newdiv.inject(catarea, 'after'); 395 var e = document.createElement('script'); 396 e.async = true; 397 if (typeof local_language != 'undefined' && $type(local_language)) { 398 e.src = document.location.protocol + '//connect.facebook.net/' + local_language + '/all.js'; 399 } 400 else { 401 e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 402 } 403 document.getElementById('fb-root').appendChild(e); 404 } 405 }()); 406 407 } 408 409}; 410 411en4.seaocore.advlightbox = { 412 createDefaultContent: function() { 413 414 } 415} 416//window.addEvent('load', function() { 417// if (typeof FB == 'undefined' && typeof fbappid != 'undefined') { 418// en4.seaocore.facebook.runFacebookSdk (); 419// } 420// 421//}); 422 423 424en4.core.runonce.add(function() { 425 426 // Reload The Page on Pop State Click (Back & Forward) Pop State Button 427 var defaultlocationHref = window.location.href; 428 var n = defaultlocationHref.indexOf('#'); 429 defaultlocationHref = defaultlocationHref.substring(0, n != -1 ? n : defaultlocationHref.length); 430 window.addEventListener("popstate", function(e) { 431 var url = window.location.href; 432 var n = url.indexOf('#'); 433 url = url.substring(0, n != -1 ? n : url.length); 434 if (e && e.state && url != defaultlocationHref) { 435 window.location.reload(true); 436 } 437 }); 438// END 439}); 440
441function addfriend(el, user_id) { 442 443 en4.core.request.send(new Request.HTML({ 444 method: 'post', 445 'url': en4.core.baseUrl + 'seaocore/feed/addfriendrequest', 446 'data': { 447 format: 'html', 448 'resource_id': user_id 449 //'action_id' : action_id, 450 }, 451 onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript) { 452 var parent = el.getParent('div'); 453 var nextSibling = el.nextSibling; 454 el.destroy(); 455 parent.insertBefore(new Element('span', { 456 'html': responseHTML 457 }), nextSibling); 458 459 } 460 }), { 461 'force': true 462 }); 463} 464 465 466 467en4.seaocore.nestedcomments = { 468 loadComments: function(type, id, page, order, parent_comment_id) { 469 470 if ($('view_more_comments_' + parent_comment_id)) { 471 $('view_more_comments_' + parent_comment_id).style.display = 'inline-block'; 472 $('view_more_comments_' + parent_comment_id).innerHTML = '<img src="application/modules/Seaocore/externals/images/core/loading.gif" alt="Loading" />'; 473 } 474 if ($('view_previous_comments_' + parent_comment_id)) { 475 $('view_previous_comments_' + parent_comment_id).style.display = 'inline-block'; 476 $('view_previous_comments_' + parent_comment_id).innerHTML = '<img src="application/modules/Seaocore/externals/images/core/loading.gif" alt="Loading" />'; 477 } 478 if ($('view_later_comments_' + parent_comment_id)) { 479 $('view_later_comments_' + parent_comment_id).style.display = 'inline-block'; 480 $('view_later_comments_' + parent_comment_id).innerHTML = '<img src="application/modules/Seaocore/externals/images/core/loading.gif" alt="Loading" />'; 481 } 482 en4.core.request.send(new Request.HTML({ 483 url: en4.core.baseUrl + 'seaocore/nestedcomment/list', 484 data: { 485 format: 'html', 486 type: type, 487 id: id, 488 page: page, 489 order: order, 490 parent_div: 1, 491 parent_comment_id: parent_comment_id 492 } 493 }), { 494 'element': $('comments' + '_' + type + '_' + id + '_' + parent_comment_id) 495 }); 496 }, 497 loadcommentssortby: function(type, id, order, parent_comment_id) { 498 if ($('sort' + '_' + type + '_' + id + '_' + parent_comment_id)) { 499 $('sort' + '_' + type + '_' + id + '_' + parent_comment_id).style.display = 'inline-block'; 500 $('sort' + '_' + type + '_' + id + '_' + parent_comment_id).innerHTML = '<img src="application/modules/Seaocore/externals/images/core/loading.gif" alt="Loading" />'; 501 } 502 en4.core.request.send(new Request.HTML({ 503 url: en4.core.baseUrl + 'seaocore/nestedcomment/list', 504 data: { 505 format: 'html', 506 type: type, 507 id: id, 508 order: order, 509 parent_div: 1, 510 parent_comment_id: parent_comment_id 511 } 512 }), { 513 'element': $('comments' + '_' + type + '_' + id + '_' + parent_comment_id) 514 }); 515 }, 516 attachCreateComment: function(formElement, type, id, parent_comment_id) { 517 var bind = this; 518 formElement.addEvent('submit', function(event) { 519 event.stop(); 520 if (formElement.body.value == '') 521 return; 522 if ($('seaocore_comment_image_' + type + '_' + id + '_' + parent_comment_id)) 523 $('seaocore_comment_image_' + type + '_' + id + '_' + parent_comment_id).destroy(); 524 var divEl = new Element('div', { 525 'class': '', 526 'html': '<img src="application/modules/Seaocore/externals/images/core/loading.gif" alt="Loading">', 527 'id': 'seaocore_comment_image_' + type + '_' + id + '_' + parent_comment_id, 528 'styles': { 529 'display': 'inline-block' 530 } 531 }); 532 533 divEl.inject(formElement); 534 var form_values = formElement.toQueryString(); 535 form_values += '&format=json'; 536 form_values += '&id=' + formElement.identity.value; 537 538 en4.core.request.send(new Request.JSON({ 539 url: en4.core.baseUrl + 'seaocore/nestedcomment/create', 540 data: form_values, 541 type: type, 542 id: id, 543 onComplete: function(e) { 544 if (parent_comment_id == 0) 545 return; 546 try { 547 var replyCount = $$('.seaocore_replies_options span')[0]; 548 var m = replyCount.get('html').match(/\d+/); 549 replyCount.set('html', replyCount.get('html').replace(m[0], e.commentsCount)); 550 } catch (e) { 551 } 552 } 553 }), { 554 'element': $('comments' + '_' + type + '_' + id + '_' + parent_comment_id) 555 }); 556 }) 557 }, 558 comment: function(type, id, body, parent_comment_id) { 559 if (body == '') 560 return; 561 var formElement = $('comments_form_' + type + '_' + id + '_' + parent_comment_id); 562 if ($('seaocore_comment_image_' + type + '_' + id + '_' + parent_comment_id)) 563 $('seaocore_comment_image_' + type + '_' + id + '_' + parent_comment_id) 564 var divEl = new Element('div', { 565 'class': '', 566 'html': '<img src="application/modules/Seaocore/externals/images/spinner.gif">', 567 'id': 'seaocore_comment_image_' + type + '_' + id + '_' + parent_comment_id, 568 'styles': { 569 'display': 'inline-block' 570 } 571 });
572 divEl.inject(formElement); 573 en4.core.request.send(new Request.JSON({ 574 url: en4.core.baseUrl + 'seaocore/nestedcomment/create', 575 data: { 576 format: 'json', 577 type: type, 578 id: id, 579 body: body 580 }, 581 onComplete: function(e) { 582 if (parent_comment_id == 0) 583 return; 584 try { 585 var replyCount = $$('.seaocore_replies_options span')[0]; 586 var m = replyCount.get('html').match(/\d+/); 587 replyCount.set('html', replyCount.get('html').replace(m[0], e.commentsCount)); 588 } catch (e) { 589 } 590 } 591 }), { 592 'element': $('comments' + '_' + type + '_' + id + '_' + parent_comment_id) 593 }); 594 }, 595 like: function(type, id, comment_id, order, parent_comment_id, option) { 596 if ($('like_comments_' + comment_id) && (option == 'child')) { 597 $('like_comments_' + comment_id).style.display = 'inline-block'; 598 $('like_comments_' + comment_id).innerHTML = '<img src="application/modules/Seaocore/externals/images/core/loading.gif" alt="Loading" />'; 599 } 600 if ($('like_comments') && (option == 'parent')) { 601 $('like_comments').style.display = 'inline-block'; 602 $('like_comments').innerHTML = '<img src="application/modules/Seaocore/externals/images/core/loading.gif" alt="Loading" />'; 603 } 604 en4.core.request.send(new Request.JSON({ 605 url: en4.core.baseUrl + 'seaocore/nestedcomment/like', 606 data: { 607 format: 'json', 608 type: type, 609 id: id, 610 comment_id: comment_id, 611 order: order, 612 parent_comment_id: parent_comment_id 613 }, 614 onComplete: function(e) { 615 if ($('sitereview_most_likes_' + id)) { 616 $('sitereview_most_likes_' + id).style.display = 'none'; 617 } 618 if ($('sitereview_unlikes_' + id)) { 619 $('sitereview_unlikes_' + id).style.display = 'block'; 620 } 621 622 if ($(type + '_like_' + id)) 623 $(type + '_like_' + id).value = 1; 624 if ($(type + '_most_likes_' + id)) 625 $(type + '_most_likes_' + id).style.display = 'none'; 626 if ($(type + '_unlikes_' + id)) 627 $(type + '_unlikes_' + id).style.display = 'inline-block'; 628 629 } 630 }), { 631 'element': $('comments' + '_' + type + '_' + id + '_' + parent_comment_id) 632 }); 633 }, 634 unlike: function(type, id, comment_id, order, parent_comment_id, option) { 635 if ($('unlike_comments_' + comment_id) && (option == 'child')) { 636 $('unlike_comments_' + comment_id).style.display = 'inline-block'; 637 $('unlike_comments_' + comment_id).innerHTML = '<img src="application/modules/Seaocore/externals/images/core/loading.gif" alt="Loading" />'; 638 } 639 if ($('unlike_comments') && (option == 'parent')) { 640 $('unlike_comments').style.display = 'inline-block'; 641 $('unlike_comments').innerHTML = '<img src="application/modules/Seaocore/externals/images/core/loading.gif" alt="Loading" />'; 642 } 643 en4.core.request.send(new Request.JSON({ 644 url: en4.core.baseUrl + 'seaocore/nestedcomment/unlike', 645 data: { 646 format: 'json', 647 type: type, 648 id: id, 649 comment_id: comment_id, 650 order: order, 651 parent_comment_id: parent_comment_id 652 }, 653 onComplete: function(e) { 654 if ($('sitereview_most_likes_' + id)) { 655 $('sitereview_most_likes_' + id).style.display = 'block'; 656 } 657 if ($('sitereview_unlikes_' + id)) { 658 $('sitereview_unlikes_' + id).style.display = 'none'; 659 } 660 661 if ($(type + '_like_' + id)) 662 $(type + '_like_' + id).value = 0; 663 if ($(type + '_most_likes_' + id)) 664 $(type + '_most_likes_' + id).style.display = 'inline-block'; 665 if ($(type + '_unlikes_' + id)) 666 $(type + '_unlikes_' + id).style.display = 'none'; 667 668 } 669 }), { 670 'element': $('comments' + '_' + type + '_' + id + '_' + parent_comment_id) 671 }); 672 }, 673 showLikes: function(type, id, order, parent_comment_id) { 674 en4.core.request.send(new Request.HTML({ 675 url: en4.core.baseUrl + 'seaocore/nestedcomment/list', 676 data: { 677 format: 'html', 678 type: type, 679 id: id, 680 viewAllLikes: true, 681 order: order, 682 parent_comment_id: parent_comment_id 683 } 684 }), { 685 'element': $('comments' + '_' + type + '_' + id + '_' + parent_comment_id) 686 });
687 }, 688 deleteComment: function(type, id, comment_id, order, parent_comment_id) { 689 if (!confirm(en4.core.language.translate('Are you sure you want to delete this?'))) { 690 return; 691 } 692 if ($('comment-' + comment_id)) { 693 $('comment-' + comment_id).destroy(); 694 } 695 (new Request.JSON({ 696 url: en4.core.baseUrl + 'seaocore/nestedcomment/delete', 697 data: { 698 format: 'json', 699 type: type, 700 id: id, 701 comment_id: comment_id, 702 order: order, 703 parent_comment_id: parent_comment_id 704 }, 705 onComplete: function(e) { 706 try { 707 var replyCount = $$('.seaocore_replies_options span')[0]; 708 var m = replyCount.get('html').match(/\d+/); 709 var newCount = (parseInt(m[0]) != 'NaN' && parseInt(m[0]) > 1 ? parseInt(m[0]) - 1 : 0); 710 replyCount.set('html', replyCount.get('html').replace(m[0], e.commentsCount)); 711 } catch (e) { 712 } 713 } 714 })).send(); 715 } 716}; 717 718var ScrollToTopSeao = function(topElementId, buttonId) { 719 window.addEvent('scroll', function() { 720 var element = $(buttonId); 721 if (element) { 722 if ($(topElementId)) { 723 var elementPostionY = 0; 724 if (typeof($(topElementId).offsetParent) != 'undefined') { 725 elementPostionY = $(topElementId).offsetTop; 726 } else { 727 elementPostionY = $(topElementId).y; 728 } 729 } 730 if (elementPostionY + window.getSize().y < window.getScrollTop()) { 731 if (element.hasClass('Offscreen')) 732 element.removeClass('Offscreen'); 733 } else if (!element.hasClass('Offscreen')) { 734 element.addClass('Offscreen'); 735 } 736 } 737 }); 738 en4.core.runonce.add(function() { 739 var scroll = new Fx.Scroll(document.getElement('body').get('id'), { 740 wait: false, 741 duration: 750, 742 offset: { 743 'x': -200, 744 'y': -100 745 }, 746 transition: Fx.Transitions.Quad.easeInOut 747 }); 748 749 $(buttonId).addEvent('click', function(event) { 750 event = new Event(event).stop(); 751 scroll.toElement(topElementId); 752 }); 753 }); 754 755}; 756 757 758ActivitySEAOUpdateHandler = new Class({ 759 Implements: [Events, Options], 760 options: { 761 debug: true, 762 baseUrl: '/', 763 identity: false, 764 delay: 5000, 765 admin: false, 766 idleTimeout: 600000, 767 last_id: 0, 768 next_id: null, 769 subject_guid: null, 770 showImmediately: false 771 }, 772 state: true, 773 activestate: 1, 774 fresh: true, 775 lastEventTime: false, 776 title: document.title, 777 //loopId : false, 778 779 initialize: function(options) { 780 this.setOptions(options); 781 }, 782 start: function() { 783 this.state = true; 784 785 // Do idle checking 786 this.idleWatcher = new IdleWatcher(this, {timeout: this.options.idleTimeout}); 787 this.idleWatcher.register(); 788 this.addEvents({ 789 'onStateActive': function() { 790 this._log('activity loop onStateActive'); 791 this.activestate = 1; 792 this.state = true; 793 }.bind(this), 794 'onStateIdle': function() { 795 this._log('activity loop onStateIdle'); 796 this.activestate = 0; 797 this.state = false; 798 }.bind(this) 799 }); 800 this.loop(); 801 //this.loopId = this.loop.periodical(this.options.delay, this); 802 }, 803 stop: function() { 804 this.state = false; 805 }, 806 checkFeedUpdate: function(action_id, subject_guid) { 807 if (en4.core.request.isRequestActive()) 808 return; 809 810 function getAllElementsWithAttribute(attribute) { 811 var matchingElements = []; 812 var values = []; 813 var allElements = document.getElementsByTagName('*'); 814 for (var i = 0; i < allElements.length; i++) { 815 if (allElements[i].getAttribute(attribute)) { 816 // Element exists with attribute. Add to array. 817 matchingElements.push(allElements[i]); 818 values.push(allElements[i].getAttribute(attribute)); 819 } 820 } 821 return values; 822 } 823 var list = getAllElementsWithAttribute('data-activity-feed-item'); 824 this.options.last_id = Math.max.apply(Math, list); 825 min_id = this.options.last_id + 1; 826 827 var req = new Request.HTML({ 828 url: en4.core.baseUrl + 'widget/index/name/seaocore.feed', 829 data: { 830 'format': 'html', 831 'minid': min_id, 832 'feedOnly': true, 833 'nolayout': true, 834 'subject': this.options.subject_guid, 835 'getUpdate': true 836 } 837 });
838 en4.core.request.send(req, { 839 'element': $('activity-feed'), 840 'updateHtmlMode': 'prepend' 841 } 842 ); 843 844 845 846 req.addEvent('complete', function() { 847 (function() { 848 if (this.options.showImmediately && $('feed-update').getChildren().length > 0) { 849 $('feed-update').setStyle('display', 'none'); 850 $('feed-update').empty(); 851 this.getFeedUpdate(this.options.next_id); 852 } 853 }).delay(50, this); 854 }.bind(this)); 855 856 857 858 // Start LOCAL STORAGE STUFF 859 if (localStorage) { 860 var pageTitle = document.title; 861 //@TODO Refill Locally Stored Activity Feed 862 863 // For each activity-item, get the item ID number Data attribute and add it to an array 864 var feed = document.getElementById('activity-feed'); 865 // For every <li> in Feed, get the Feed Item Attribute and add it to an array 866 var items = feed.getElementsByTagName("li"); 867 var itemObject = {}; 868 // Loop through each item in array to get the InnerHTML of each Activity Feed Item 869 var c = 0; 870 for (var i = 0; i < items.length; ++i) { 871 if (items[i].getAttribute('data-activity-feed-item') != null) { 872 var itemId = items[i].getAttribute('data-activity-feed-item'); 873 itemObject[c] = {id: itemId, content: document.getElementById('activity-item-' + itemId).innerHTML}; 874 c++; 875 } 876 } 877 // Serialize itemObject as JSON string 878 var activityFeedJSON = JSON.stringify(itemObject); 879 localStorage.setItem(pageTitle + '-activity-feed-widget', activityFeedJSON); 880 } 881 882 883 // Reconstruct JSON Object, Find Highest ID 884 if (localStorage.getItem(pageTitle + '-activity-feed-widget')) { 885 var storedFeedJSON = localStorage.getItem(pageTitle + '-activity-feed-widget'); 886 var storedObj = eval("(" + storedFeedJSON + ")"); 887 888 //alert(storedObj[0].id); // Highest Feed ID 889 // @TODO use this at min_id when fetching new Activity Feed Items 890 } 891 // END LOCAL STORAGE STUFF 892 893 894 return req; 895 }, 896 getFeedUpdate: function(last_id) { 897 if (en4.core.request.isRequestActive()) 898 return; 899 var min_id = this.options.last_id + 1; 900 this.options.last_id = last_id; 901 document.title = this.title; 902 var req = new Request.HTML({ 903 url: en4.core.baseUrl + 'widget/index/name/seaocore.feed', 904 data: { 905 'format': 'html', 906 'minid': min_id, 907 'feedOnly': true, 908 'nolayout': true, 909 'getUpdate': true, 910 'subject': this.options.subject_guid 911 } 912 }); 913 en4.core.request.send(req, { 914 'element': $('activity-feed'), 915 'updateHtmlMode': 'prepend' 916 }); 917 return req; 918 }, 919 loop: function() { 920 this._log('activity update loop start'); 921 922 if (!this.state) { 923 this.loop.delay(this.options.delay, this); 924 return; 925 } 926 927 try { 928 this.checkFeedUpdate().addEvent('complete', function() { 929 try { 930 this._log('activity loop req complete'); 931 this.loop.delay(this.options.delay, this); 932 } catch (e) { 933 this.loop.delay(this.options.delay, this); 934 this._log(e); 935 } 936 }.bind(this)); 937 } catch (e) { 938 this.loop.delay(this.options.delay, this); 939 this._log(e); 940 } 941 942 this._log('activity update loop stop'); 943 }, 944 // Utility 945 _log: function(object) { 946 if (!this.options.debug) { 947 return; 948 } 949 950 try { 951 if ('console' in window && typeof(console) && 'log' in console) { 952 console.log(object); 953 } 954 } catch (e) { 955 // Silence 956 } 957 } 958}); 959 960en4.seaocore.locationBased = { 961 startReq: function(params) { 962 window.locationsParamsSEAO = { 963 latitude: 0, 964 longitude: 0 965 }; 966 window.locationsDetactSEAO = false; 967 params.isExucute = false; 968 var self = this; 969 var callBackFunction = self.sendReq; 970 if (params.callBack) { 971 callBackFunction = params.callBack; 972 } 973 974 if (params.detactLocation && !window.locationsDetactSEAO && navigator.geolocation) { 975
976 if (typeof(Cookie.read('seaocore_myLocationDetails')) != 'undefined' && Cookie.read('seaocore_myLocationDetails') != "") { 977 var readLocationsDetails = JSON.parse(Cookie.read('seaocore_myLocationDetails')); 978 } 979 980 if (typeof(readLocationsDetails) == 'undefined' || readLocationsDetails == null || typeof(readLocationsDetails.latitude) == 'undefined' || typeof(readLocationsDetails.longitude) == 'undefined') { 981 982 navigator.geolocation.getCurrentPosition(function(position) { 983 984 985 if($('region')){ 986 var regionCurrentLocation = $('region').innerHTML; 987 $('region').innerHTML = '<div class="seaocore_content_loader"></div>'; 988 } 989 990 window.locationsParamsSEAO.latitude = position.coords.latitude; 991 window.locationsParamsSEAO.longitude = position.coords.longitude; 992 993 var myLocationDetails = {'latitude': position.coords.latitude, 'longitude': position.coords.longitude, 'location': '', 'locationmiles': params.locationmiles}; 994 self.setLocationCookies(myLocationDetails); 995 996 self.setLocationField(position, params); 997 params.locationSetInCookies = true; 998 params.requestParams = $merge(params.requestParams, window.locationsParamsSEAO); 999 params.isExucute = true; 1000 if (typeof(params.noSendReq) == 'undefined' || params.noSendReq == null) { 1001 callBackFunction(params); 1002 } 1003 1004 }, function() { 1005 params.isExucute = true; 1006 if (typeof(params.noSendReq) == 'undefined' || params.noSendReq == null) { 1007 callBackFunction(params); 1008 } 1009 1010 }); 1011 } 1012 else { 1013 window.locationsParamsSEAO.latitude = readLocationsDetails.latitude; 1014 window.locationsParamsSEAO.longitude = readLocationsDetails.longitude; 1015 params.requestParams = $merge(params.requestParams, window.locationsParamsSEAO); 1016 params.isExucute = true; 1017 if (typeof(params.noSendReq) == 'undefined' || params.noSendReq == null) { 1018 callBackFunction(params); 1019 } 1020 } 1021 1022 window.locationsDetactSEAO = true; 1023 window.setTimeout(function() { 1024 if (params.isExucute) 1025 return; 1026 1027 if (typeof(params.noSendReq) == 'undefined' || params.noSendReq == null) { 1028 callBackFunction(params); 1029 } 1030 1031 }, 3000); 1032 } else { 1033 if (params.detactLocation && window.locationsDetactSEAO) { 1034 params.requestParams = $merge(params.requestParams, window.locationsParamsSEAO); 1035 } 1036 1037 if (typeof(params.noSendReq) == 'undefined' || params.noSendReq == null) { 1038 callBackFunction(params); 1039 } 1040 } 1041 1042 }, 1043 sendReq: function(params) { 1044 1045 var self = this; 1046 var url = en4.core.baseUrl + 'widget'; 1047 1048 if (params.requestUrl) 1049 url = params.requestUrl; 1050 var request = new Request.HTML({ 1051 url: url, 1052 data: $merge(params.requestParams, { 1053 format: 'html', 1054 subject: en4.core.subject.guid, 1055 is_ajax_load: true 1056 }), 1057 evalScripts: true, 1058 onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript) { 1059 if ($(params.responseContainer)) { 1060 $(params.responseContainer).innerHTML = ''; 1061 Elements.from(responseHTML).inject($(params.responseContainer)); 1062 } 1063 en4.core.runonce.trigger(); 1064 Smoothbox.bind(params.responseContainer); 1065 } 1066 }); 1067 request.send(); 1068 1069 }, 1070 setLocationCookies: function(params, pageReload) { 1071 1072 var myLocationDetails = {'latitude': params.latitude, 'longitude': params.longitude, 'location': params.location, 'locationmiles': params.locationmiles}; 1073 1074 if (typeof(params.changeLocationWidget) != 'undefined' && params.changeLocationWidget) { 1075 Cookie.write('seaocore_myLocationDetails', JSON.stringify(myLocationDetails), {duration: 30, path: en4.core.baseUrl}); 1076 } 1077 else { 1078 en4.core.request.send(new Request.JSON({ 1079 url: en4.core.baseUrl + 'seaocore/location/get-specific-location-setting', 1080 data: { 1081 format: 'json', 1082 location: params.location, 1083 updateUserLocation: params.updateUserLocation 1084 }, 1085 onSuccess: function(responseJSON) { 1086 if(responseJSON.saveCookies) {
1087 Cookie.write('seaocore_myLocationDetails', JSON.stringify(myLocationDetails), {duration: 30, path: en4.core.baseUrl}); 1088 1089 if (pageReload) { 1090 window.location.reload(); 1091 } 1092 1093 } 1094 } 1095 }),{force:true}); 1096 } 1097 1098 1099 1100 1101 }, 1102 setLocationField: function(position, params) { 1103 var self = this; 1104 if (!position.address) { 1105 var mapDetect = new google.maps.Map(new Element('div'), { 1106 mapTypeId: google.maps.MapTypeId.ROADMAP, 1107 center: new google.maps.LatLng(0, 0) 1108 }); 1109 var service = new google.maps.places.PlacesService(mapDetect); 1110 var request = { 1111 location: new google.maps.LatLng(position.coords.latitude, position.coords.longitude), 1112 radius: 500 1113 }; 1114 service.search(request, function(results, status) { 1115 if (status == 'OK') { 1116 var index = 0; 1117 var radian = 3.141592653589793 / 180; 1118 var my_distance = 1000; 1119 var R = 6371; // km 1120 for (var i = 0; i < results.length; i++) { 1121 var lat2 = results[i].geometry.location.lat(); 1122 var lon2 = results[i].geometry.location.lng(); 1123 var dLat = (lat2 - position.coords.latitude) * radian; 1124 var dLon = (lon2 - position.coords.longitude) * radian; 1125 var lat1 = position.coords.latitude * radian; 1126 lat2 = lat2 * radian; 1127 var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2); 1128 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); 1129 var d = R * c; 1130 1131 if (d < my_distance) { 1132 index = i; 1133 my_distance = d; 1134 } 1135 } 1136 1137 if (typeof(params.fieldName) != 'undefined' && params.fieldName != null && document.getElementById(params.fieldName)) { 1138 document.getElementById(params.fieldName).value = (results[index].vicinity) ? results[index].vicinity : ''; 1139 1140 if (typeof(params.locationmilesFieldName) != 'undefined' && params.locationmilesFieldName != null && document.getElementById(params.locationmilesFieldName)) { 1141 document.getElementById(params.locationmilesFieldName).value = params.locationmiles; 1142 } 1143 } 1144 1145 var cookiesLocation = (results[index].vicinity) ? results[index].vicinity : ''; 1146 var myLocationDetails = {'latitude': position.coords.latitude, 'longitude': position.coords.longitude, 'location': cookiesLocation, 'locationmiles': params.locationmiles}; 1147 1148 var pageReload = 0; 1149 if (typeof(params.reloadPage) != 'undefined' && params.reloadPage != null) { 1150 pageReload = 1; 1151 } 1152 1153 self.setLocationCookies(myLocationDetails, pageReload); 1154 1155// if (typeof(params.reloadPage) != 'undefined' && params.reloadPage != null) { 1156// window.location.reload(); 1157// } 1158 1159 } 1160 }) 1161 } else { 1162 var delimiter = (position.address && position.address.street != '' && position.address.city != '') ? ', ' : ''; 1163 var location = (position.address) ? (position.address.street + delimiter + position.address.city) : ''; 1164 if (typeof(params.fieldName) != 'undefined' && params.fieldName != null && document.getElementById(params.fieldName)) { 1165 document.getElementById(params.fieldName).value = location; 1166 } 1167 1168 var myLocationDetails = {'latitude': position.coords.latitude, 'longitude': position.coords.longitude, 'location': location, 'locationmiles': params.locationmiles}; 1169 1170 var pageReload = 0; 1171 if (typeof(params.reloadPage) != 'undefined' && params.reloadPage != null) { 1172 pageReload = 1; 1173 } 1174 1175 self.setLocationCookies(myLocationDetails, pageReload); 1176 1177// if (typeof(params.reloadPage) != 'undefined' && params.reloadPage != null) { 1178// window.location.reload(); 1179// } 1180 1181 } 1182 1183 }, 1184}; 1185en4.seaocore.setShareButtons = function(wrapper, cont, params) { 1186 en4.seaocore.setDomElements(); 1187 if (cont.getElement('.facebook_container')) { 1188 if (!document.getElementById('fb-root')) 1189 new Element('div', {'id': 'fb-root'}).inject($(en4.seaocore.contentElement), 'top'); 1190 (function(d, s, id) { 1191 var js, fjs = d.getElementsByTagName(s)[0]; 1192 if (d.getElementById(id)) 1193 return; 1194 js = d.createElement(s); 1195 js.id = id; 1196 if (typeof local_language != 'undefined' && $type(local_language)) { 1197 js.src = "//connect.facebook.net/"+ local_language +"/all.js#xfbml=1"; 1198 } 1199 else { 1200 js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; 1201 } 1202 fjs.parentNode.insertBefore(js, fjs); 1203 }(document, 'script', 'facebook-jssdk')); 1204 } 1205 1206 if (cont.getElement('.linkedin_container')) { 1207 new Element('script', {'type': 'IN/Share', 'data-counter': 'top'}).inject(cont.getElement('.linkedin_container')); 1208 new Element('script', {'src': ("https:" == document.location.protocol ? "https://" : "http://") + 'platform.linkedin.com/in.js'}).inject($(en4.seaocore.contentElement), 'before'); 1209 1210 } 1211 if (cont.getElement('.twitter_container')) { 1212 new Element('script', {'src': ("https:" == document.location.protocol ? "https://" : "http://") + 'platform.twitter.com/widgets.js'}).inject($(en4.seaocore.contentElement), 'before'); 1213 1214 } 1215 if (cont.getElement('.google_container')) { 1216 new Element('script', {'src': 'https://apis.google.com/js/plusone.js', 'async': true}).inject($(en4.seaocore.contentElement), 'before'); 1217 1218 } 1219 1220 if (!params.leftValue) { 1221 params.leftValue = 15; 1222 } 1223 wrapper.inject($(en4.seaocore.contentElement), 'top'); 1224 var top = wrapper.getStyle('top'); 1225 if (!params.type) { 1226 params.type = 'left'; 1227 } 1228 1229 if (params.type === 'left') { 1230 params.leftValue = params.leftValue + parseInt(wrapper.clientWidth);
1231 cont.setStyle('left', '-' + params.leftValue + 'px'); 1232 $(en4.seaocore.contentElement).addClass('seao_share_buttons_left_content'); 1233 } else { 1234 params.leftValue = params.leftValue + parseInt($(en4.seaocore.contentElement).clientWidth); 1235 cont.setStyle('left', params.leftValue + 'px'); 1236 $(en4.seaocore.contentElement).addClass('seao_share_buttons_right_content'); 1237 } 1238 (function() { 1239 wrapper.setStyles({width: '1px', visibility: 'visible'}); 1240 }).delay(1500); 1241 window.addEvent('scroll', function(e) { 1242 var descripY = parseInt($(en4.seaocore.contentElement).getOffsets().y) - 20, scrollY = $(window).getScroll().y, footerY = parseInt($(en4.seaocore.footerElement).getOffsets().y), height = parseInt(wrapper.getStyle('height')), fixedShare = wrapper.getStyle('position') === 'fixed'; 1243 1244 if (scrollY < descripY && fixedShare) { 1245 wrapper.setStyles({ 1246 position: 'absolute', 1247 top: top 1248 }); 1249 } 1250 else if (scrollY > descripY && (scrollY + 20 + height) > footerY) { 1251 wrapper.setStyles({ 1252 position: 'absolute', 1253 top: (footerY - height - 90) 1254 }); 1255 } 1256 else if (scrollY > descripY && !fixedShare) { 1257 wrapper.setStyles({ 1258 position: 'fixed', 1259 top: 20 1260 }); 1261 } 1262 }); 1263 $$('.generic_layout_container.layout_seaocore_social_share_buttons')[0].style.display = 'none'; 1264}; 1265 1266var SmoothboxSEAO = { 1267 overlay: null, 1268 wrapper: null, 1269 content: null, 1270 contentHTML: null, 1271 scrollPosition: { 1272 left: 0, 1273 top: 0 1274 }, 1275 addScriptFiles: [], 1276 addStylesheets: [], 1277 active: false, 1278 closable: true, 1279 build: function() { 1280 SmoothboxSEAO.overlay = new Element('div', { 1281 'class': 'seao_smoothbox_lightbox_overlay' 1282 }).inject($(en4.seaocore.contentWrapperElement)); 1283 SmoothboxSEAO.wrapper = new Element('div', { 1284 'class': 'seao_smoothbox_lightbox_content_wrapper' 1285 }).inject($(en4.seaocore.contentWrapperElement)); 1286 SmoothboxSEAO.attach(); 1287 SmoothboxSEAO.hide(); 1288 }, 1289 attach: function() { 1290 if (!SmoothboxSEAO.wrapper || !SmoothboxSEAO.closable) 1291 return; 1292 SmoothboxSEAO.wrapper.removeEvents('click').addEvent('click', function(event) { 1293 var el = $(event.target); 1294 if (el.hasClass('seao_smoothbox_lightbox_content') || el.getParent('.seao_smoothbox_lightbox_content')) 1295 return; 1296 SmoothboxSEAO.close(); 1297 }); 1298 }, 1299 bind: function(selector) { 1300 // All children of element 1301 var elements; 1302 if ($type(selector) == 'element') { 1303 elements = selector.getElements('a.seao_smoothbox'); 1304 } else if ($type(selector) == 'string') { 1305 elements = $$(selector); 1306 } else { 1307 elements = $$("a.seao_smoothbox"); 1308 } 1309 1310 elements.each(function(el) 1311 { 1312 if (el.get('tag') != 'a' || !SmoothboxSEAO.hasLink(el) || el.retrieve('smoothboxed', false)) 1313 { 1314 return; 1315 } 1316 1317 1318 el.addEvent('click', function(event) { 1319 event.stop(); 1320 if (el.get('data-SmoothboxSEAOType') == 'iframe') { 1321 SmoothboxSEAO.open({ 1322 class: el.get('data-SmoothboxSEAOClass'), 1323 iframe: { 1324 src: el.href 1325 } 1326 }); 1327 } else { 1328 SmoothboxSEAO.open({ 1329 class: el.get('data-SmoothboxSEAOClass'), 1330 request: { 1331 url: el.href 1332 } 1333 }); 1334 } 1335 }); 1336 el.store('smoothboxed', true); 1337 }); 1338 1339 1340 }, 1341 hasLink: function(element) { 1342 return ( 1343 !element.onclick && 1344 element.href && 1345 !element.href.match(/^(javascript|[#])/)); 1346 }, 1347 open: function(params) { 1348 if (!params) 1349 return; 1350 if( !SmoothboxSEAO.wrapper ) { 1351 if( (typeof params.closable) === 'boolean' && params.closable === false ) { 1352 SmoothboxSEAO.closable = false; 1353 } 1354 SmoothboxSEAO.build(); 1355 } else { 1356 SmoothboxSEAO.wrapper.empty(); 1357 } 1358 if ((typeof params) === 'string') { 1359 if (params.length < 4000 && (params.substring(0, 1) == '/' || 1360 params.substring(0, 1) == '.' || 1361 params.substring(0, 4) == 'http' || 1362 !params.match(/[ <>"'{}|^~\[\]`]/) 1363 ) 1364 ) { 1365 1366 params = {request: { 1367 url: params 1368 }}; 1369 } else { 1370 params = {element: params}; 1371 } 1372 1373 } else if ($type(params) === 'element') { 1374 params = {element: params}; 1375 } 1376 1377 SmoothboxSEAO.content = new Element('div', { 1378 'class': 'seao_smoothbox_lightbox_content' 1379 }).inject(SmoothboxSEAO.wrapper); 1380 // SmoothboxSEAO.content.setStyle('width', 'auto');
1381 SmoothboxSEAO.contentHTML = new Element('div', { 1382 'class': 'seao_smoothbox_lightbox_content_html' 1383 }).inject(SmoothboxSEAO.content); 1384 if (params.class) 1385 SmoothboxSEAO.content.addClass(params.class); 1386 1387 if (params.element && (typeof params.element) === 'string') 1388 SmoothboxSEAO.contentHTML.innerHTML = params.element; 1389 else if (params.element) 1390 params.element.inject(SmoothboxSEAO.contentHTML); 1391 else if (params.request && params.request.url) 1392 SmoothboxSEAO.sendReq(params.request); 1393 else if (params.iframe && params.iframe.src) 1394 SmoothboxSEAO.iframeReq(params.iframe); 1395 else if (params.embed && params.embed.code) 1396 SmoothboxSEAO.embed(params.embed); 1397 SmoothboxSEAO.show(); 1398 $$(".seao_smoothbox_lightbox_close").addEvent('click', function(event) { 1399 event.stopPropagation(); 1400 SmoothboxSEAO.close(); 1401 }); 1402 1403 SmoothboxSEAO.doAutoResize(); 1404 // this.fireEvent('open', this); 1405 }, 1406 embed: function (options) { 1407 var elementWapper = new Element('div', { 1408 'class': 'seao_smoothbox_iframe_wapper ' + (options.wapperClass ? options.wapperClass : '') , 1409 html: '<a class="seao_smoothbox_lightbox_close _close" href="javascript:void();"><i class="fa fa-close"></i></a>' 1410 }); 1411 var elementContent = new Element('div', { 1412 'class': 'seao_smoothbox_iframe_content ' + (options.contentClass ? options.contentClass : ''), 1413 html: options.code 1414 }); 1415 elementContent.inject(elementWapper); 1416 elementWapper.inject(SmoothboxSEAO.contentHTML); 1417 SmoothboxSEAO.content.addClass('seao_smoothbox_iframe'); 1418 SmoothboxSEAO.wrapper.addClass('seao_smoothbox_wapper-iframe'); 1419 }, 1420 _getEmbedIframeTarget: function(src) { 1421 var _youtubeRegex = /(youtube(-nocookie)?\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed\/?)?([\w-]{11})(.*)?/i; 1422 var _instagramRegex = /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?\??(.*)?/i; 1423 var _vimeoRegex = /(vimeo(pro)?\.com)\/(?:[^\d]+)?(\d+)\??(.*)?$/; 1424 var _facebookRegex = /(facebook\.com)\/([a-z0-9_-]*)\/videos\/([0-9]*)(.*)?$/i; 1425 var target = {}, matches; 1426 matches = src.match(_youtubeRegex); 1427 if (matches) { 1428 target.type = 'youtube'; 1429 target.src = 'https://www.youtube' + (matches[2] || '') + '.com/embed/' + matches[4] + '?autoplay=1'; 1430 return target; 1431 } 1432 1433 matches = src.match(_vimeoRegex); 1434 if (matches) { 1435 target.type = 'vimeo'; 1436 target.src = 'https://player.vimeo.com/video/' + matches[3] + '?autoplay=1'; 1437 return target; 1438 } 1439 1440 matches = src.match(_facebookRegex); 1441 if (matches) { 1442 if (0 !== src.indexOf('http')) { 1443 src = 'https:' + src; 1444 } 1445 target.type = 'facebook'; 1446 target.src = 'https://www.facebook.com/plugins/video.php?href=' + src + '&autoplay=1'; 1447 return target; 1448 } 1449 1450 matches = src.match(_instagramRegex); 1451 if (matches) { 1452 target.type = 'instagram'; 1453 target.src = 'https://www.instagram.com/p/' + matches[2] + '/embed/'; 1454 return target; 1455 } 1456 1457 target.type = 'website'; 1458 target.src = src; 1459 return target; 1460 }, 1461 iframeReq: function (options) { 1462 var elementWapper = new Element('div', { 1463 'class': 'seao_smoothbox_iframe_wapper ' + (options.wapperClass ? options.wapperClass : ''), 1464 html: '<a class="seao_smoothbox_lightbox_close _close" href="javascript:void();"><i class="fa fa-close"></i></a>' 1465 }); 1466 var elementContent = new Element('div', { 1467 'class': 'seao_smoothbox_iframe_content ' + (options.contentClass ? options.contentClass : ''), 1468 }); 1469 var target = SmoothboxSEAO._getEmbedIframeTarget(options.src); 1470 SmoothboxSEAO.frame = new IFrame({ 1471 src: target.src, 1472 name: 'SmoothboxSEAO_iframe', 1473 frameborder: 0, 1474 webkitallowfullscreen: true, 1475 mozallowfullscreen: true, 1476 allowfullscree: true 1477 }); 1478 SmoothboxSEAO.frame.inject(elementContent); 1479 elementContent.inject(elementWapper); 1480 elementWapper.inject(SmoothboxSEAO.contentHTML); 1481 SmoothboxSEAO.content.addClass('seao_smoothbox_iframe seao_smoothbox_iframe_' + target.type); 1482 SmoothboxSEAO.wrapper.addClass('seao_smoothbox_wapper-iframe'); 1483 }, 1484 doAutoResize: function() { 1485 //return; 1486 var size = Function.attempt(function() {
1487 return SmoothboxSEAO.contentHTML.getScrollSize(); 1488 }, function() { 1489 return SmoothboxSEAO.contentHTML.getSize(); 1490 }, function() { 1491 return { 1492 x: SmoothboxSEAO.contentHTML.scrollWidth, 1493 y: SmoothboxSEAO.contentHTML.scrollHeight 1494 } 1495 }); 1496 1497 // if (size.x) { 1498 var winSize = window.getSize(); 1499 if (size.x > (winSize.x - 30)) { 1500 size.x = winSize.x - 30; 1501 } 1502 var marginTop = 10; 1503 SmoothboxSEAO.content.setStyle('width', size.x); 1504 if (size.y < winSize.y) { 1505 marginTop = (winSize.y - size.y) / 2; 1506 } 1507 1508 if (marginTop < 10) 1509 marginTop = 10; 1510 size.x = size.x + 10; 1511 SmoothboxSEAO.content.setStyles({ 1512 'width': size.x, 1513 'marginTop': marginTop, 1514 'marginBottom': 20 1515 }); 1516 // } 1517 }, 1518 show: function() { 1519 SmoothboxSEAO.overlay.show(); 1520 SmoothboxSEAO.wrapper.show(); 1521 if ($('arrowchat_base')) 1522 $('arrowchat_base').style.display = 'none'; 1523 if ($('wibiyaToolbar')) 1524 $('wibiyaToolbar').style.display = 'none'; 1525 SmoothboxSEAO.scrollPosition.top = window.getScrollTop(); 1526 SmoothboxSEAO.scrollPosition.left = window.getScrollLeft(); 1527 SmoothboxSEAO.setHtmlScroll("hidden"); 1528 SmoothboxSEAO.active = true; 1529 }, 1530 hide: function() { 1531 SmoothboxSEAO.overlay.hide(); 1532 SmoothboxSEAO.wrapper.hide(); 1533 SmoothboxSEAO.active = false; 1534 }, 1535 close: function() { 1536 if (!SmoothboxSEAO.active) 1537 return; 1538 SmoothboxSEAO.hide(); 1539 SmoothboxSEAO.wrapper.empty(); 1540 SmoothboxSEAO.wrapper.removeClass('seao_smoothbox_wapper-iframe'); 1541 SmoothboxSEAO.setHtmlScroll("auto"); 1542 window.scroll(SmoothboxSEAO.scrollPosition.left, SmoothboxSEAO.scrollPosition.top); 1543 if ($('arrowchat_base')) 1544 $('arrowchat_base').style.display = 'block'; 1545 if ($('wibiyaToolbar')) 1546 $('wibiyaToolbar').style.display = 'block'; 1547 // this.fireEvent('close', this); 1548 }, 1549 setHtmlScroll: function(cssCode) { 1550 $$('html').setStyle('overflow', cssCode); 1551 }, 1552 sendReq: function(params) { 1553 var container = SmoothboxSEAO.contentHTML; 1554 container.empty(); 1555 new Element('div', { 1556 'class': 'seao_smoothbox_lightbox_loading' 1557 }).inject(container); 1558 1559 if (!params.requestParams) 1560 params.requestParams = {}; 1561 SmoothboxSEAO.addScriptFiles = []; 1562 SmoothboxSEAO.addStylesheets = []; 1563 1564 var request = new Request.HTML({ 1565 url: params.url, 1566 method: 'get', 1567 data: $merge(params.requestParams, { 1568 format: 'html', 1569 seaoSmoothbox: true 1570 }), 1571 evalScripts: true, 1572 onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript) { 1573 var onLoadContent = function() { 1574 container.empty(); 1575 Elements.from(responseHTML).inject(container); 1576 en4.core.runonce.trigger(); 1577 SmoothboxSEAO.doAutoResize(); 1578 Smoothbox.bind(container); 1579 SmoothboxSEAO.bind(container); 1580 $$(".seao_smoothbox_lightbox_close").addEvent('click', function(event) { 1581 event.stopPropagation(); 1582 SmoothboxSEAO.close(); 1583 }); 1584 if (params.callBack && (typeof params.callBack) === 'function') { 1585 params.callBack(container); 1586 } 1587 }; 1588 var JSCount = SmoothboxSEAO.addScriptFiles.length; 1589 var StyleSheetCount = SmoothboxSEAO.addStylesheets.length; 1590 var totalFiles = JSCount + StyleSheetCount; 1591 var i = 0, succes = 0; 1592 if (succes === totalFiles) 1593 onLoadContent(); 1594 for (i; i < JSCount; i++) { 1595 Asset.javascript(SmoothboxSEAO.addScriptFiles[i], { 1596 onLoad: function() { 1597 succes++; 1598 if (succes === totalFiles) 1599 onLoadContent(); 1600 }}); 1601 } 1602 SmoothboxSEAO.addScriptFiles = []; 1603 for (i = 0; i < StyleSheetCount; i++) { 1604 Asset.css(SmoothboxSEAO.addStylesheets[i], { 1605 onLoad: function() { 1606 succes++; 1607 if (succes === totalFiles) 1608 onLoadContent(); 1609 }}); 1610 } 1611 SmoothboxSEAO.addStylesheets = []; 1612 1613 } 1614 });
1615 request.send(); 1616 } 1617}; 1618 1619en4.seaocore.socialService = { 1620 clickHandler: function (el) { 1621 var request = new Request.JSON({ 1622 url: en4.core.baseUrl + 'siteshare/index/social-service-click', 1623 method: 'post', 1624 data: { 1625 format: 'json', 1626 shareUrl: $(el).get('data-url'), 1627 serviceType: $(el).get('data-service') 1628 }, 1629 onSuccess: function(){ 1630 1631 } 1632 }); 1633 request.send(); 1634 } 1635}; 1636window.addEvent('domready', function() 1637{ 1638 SmoothboxSEAO.bind(); 1639}); 1640 1641window.addEvent('load', function() 1642{ 1643 SmoothboxSEAO.bind(); 1644}); 1645 1646en4.seaocore.covertdateDmyToMdy = function(date) { 1647 starttime = date.split("/"); 1648 date = starttime[1] + '/' + starttime[0] + '/' + starttime[2]; 1649 return date; 1650}; 1651 1652 1653/* Community Ad Plugin JS Start here*/ 1654en4.communityad = { 1655 sendReq: function(container, content_id, isAdboardPage, requestParams) { 1656 var url = en4.core.baseUrl + 'widget'; 1657 var params = { 1658 format: 'html', 1659 is_ajax_load: 1, 1660 subject: en4.core.subject.guid, 1661 isAdboardPage: isAdboardPage 1662 }; 1663 if (!content_id) { 1664 url = en4.core.baseUrl + 'widget/index/mod/communityad/name/ads'; 1665 } else { 1666 params.content_id = content_id; 1667 } 1668 if (requestParams) 1669 params = $merge(requestParams, params); 1670 var request = new Request.HTML({ 1671 url: url, 1672 method: 'get', 1673 data: params, 1674 onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript) { 1675 container.empty(); 1676 Elements.from(responseHTML).inject(container); 1677 en4.core.runonce.trigger(); 1678 Smoothbox.bind(container); 1679 } 1680 }); 1681 request.send(); 1682 } 1683}; 1684var communityad_likeinfo = function(ad_id, resource_type, resource_id, owner_id, widgetType, core_like) { 1685 // SENDING REQUEST TO AJAX 1686 var request = createLike(ad_id, resource_type, resource_id, owner_id, widgetType, core_like); 1687 // RESPONCE FROM AJAX 1688 request.addEvent('complete', function(responseJSON) { 1689 if (responseJSON.like_id) 1690 { 1691 $(widgetType + '_likeid_info_' + ad_id).value = responseJSON.like_id; 1692 $(resource_type + '_' + widgetType + '_most_likes_' + ad_id).style.display = 'none'; 1693 $(resource_type + '_' + widgetType + '_unlikes_' + ad_id).style.display = 'block'; 1694 } 1695 else 1696 { 1697 $(widgetType + '_likeid_info_' + ad_id).value = 0; 1698 $(resource_type + '_' + widgetType + '_most_likes_' + ad_id).style.display = 'block'; 1699 $(resource_type + '_' + widgetType + '_unlikes_' + ad_id).style.display = 'none'; 1700 } 1701 }); 1702} 1703/* $Id: core.js 2011-02-16 9:40:21Z SocialEngineAddOns Copyright 2009-2011 BigStep Technologies Pvt. Ltd. $ */ 1704 1705// Use: Ads Display. 1706// Function Call: When click on cross of any advertisment. 1707function adCancel(div_id, widgetType) { 1708 $(widgetType + '_ad_cancel_' + div_id).style.display = 'block'; 1709 $(widgetType + '_ad_' + div_id).style.display = 'none'; 1710} 1711 1712// Use: Ads Display. 1713// Function Call: After click on cross of any ads then show option of 'undo' if click on the 'undo'. 1714function adUndo(div_id, widgetType) { 1715 $(widgetType + '_ad_cancel_' + div_id).style.display = 'none'; 1716 $(widgetType + '_ad_' + div_id).style.display = 'block'; 1717 if ($(widgetType + '_other_' + div_id).checked) { 1718 $(widgetType + '_other_' + div_id).checked = false; 1719 $(widgetType + '_other_text_' + div_id).style.display = 'none'; 1720 $(widgetType + '_other_text_' + div_id).value = 'Type your reason here...'; 1721 $(widgetType + '_other_button_' + div_id).style.display = 'none'; 1722 } 1723} 1724 1725// Use: Ads Display. 1726// Function Call: After click on cross of any ads then show radio button if click on 'other' type radio button. 1727function otherAdCannel(adRadioValue, div_id, widgetType) { 1728 // Condition: When click on 'other radio button'. 1729 if (adRadioValue == 4) { 1730 $(widgetType + '_other_text_' + div_id).style.display = 'block'; 1731 $(widgetType + '_other_button_' + div_id).style.display = 'block'; 1732 } 1733} 1734 1735// Use: Ads Display 1736// Function Call: When save entry in data base. 1737function adSave(adCancelReasion, adsId, divId, widgetType) { 1738 var adDescription = 0; 1739 // Condition: Find out 'Description' if select other options from radio button. 1740 1741 if (adCancelReasion == 'Other') { 1742 if ($(widgetType + '_other_text_' + divId).value != 'Type your reason here...') { 1743 adDescription = $(widgetType + '_other_text_' + divId).value; 1744 } 1745 } 1746 $(widgetType + '_ad_cancel_' + divId).innerHTML = '<center><img src="application/modules/Seaocore/externals/images/core/loading.gif" alt=""></center>'; 1747 en4.core.request.send(new Request.HTML({ 1748 url: en4.core.baseUrl + 'communityad/display/adsave', 1749 data: { 1750 format: 'html', 1751 adCancelReasion: adCancelReasion, 1752 adDescription: adDescription, 1753 adsId: adsId 1754 } 1755 }), { 1756 'element': $(widgetType + '_ad_cancel_' + divId) 1757 }) 1758} 1759 1760// Function: For 'Advertisment' liked or unliked. 1761function createLike(ad_id, resource_type, resource_id, owner_id, widgetType, core_like) 1762{ 1763 var like_id = $(widgetType + '_likeid_info_' + ad_id).value; 1764 var request = new Request.JSON({ 1765 url: en4.core.baseUrl + 'communityad/display/globallikes', 1766 data: { 1767 format: 'json', 1768 'ad_id': ad_id, 1769 'resource_type': resource_type, 1770 'resource_id': resource_id, 1771 'owner_id': owner_id, 1772 'like_id': like_id, 1773 'core_like': core_like 1774 } 1775 }); 1776 request.send(); 1777 return request; 1778} 1779/* Community Ad Plugin JS End here*/ 1780 1781function locationAutoSuggest(countrycities, location_field, city_field) { 1782
1783 if(city_field && $(city_field)) { 1784 1785 if(countrycities) { 1786 var options = { 1787 types: ['(cities)'], 1788 componentRestrictions: {country: countrycities} 1789 }; 1790 } 1791 else { 1792 var options = { 1793 types: ['(cities)'] 1794 }; 1795 } 1796 1797 var autocomplete = new google.maps.places.Autocomplete($(city_field), options); 1798 } 1799 1800 if(location_field && $(location_field)) { 1801 1802 if(countrycities) { 1803 var options = { 1804 //types: [''],//We are not passing any values here for showing all results of some specific country. 1805 componentRestrictions: {country: countrycities} 1806 }; 1807 } 1808 else { 1809 var options = { 1810 1811 }; 1812 } 1813 1814 var autocomplete = new google.maps.places.Autocomplete($(location_field), options); 1815 } 1816 1817} 1818 1819//WHEN CONTENT ON THE PAGE LOAD FROM THE AJAX IN THAT CASE SMOOTHBOX CLASS DOES NOT WORK THEN WE USE BELOW FUNCTION 1820function openSmoothbox(thisobj) { 1821 var Obj_Url = thisobj.href; 1822 Smoothbox.open(Obj_Url); 1823} 1824 1825function showShareLinks(val) { 1826 $(document.body).addEvent('click', showHideToggleShareLinks); 1827 $$('.siteevent_share_links_toggle').removeEvents('click').addEvent('click',function(event) { 1828 event.stop(); 1829 //showHideToggleShareLinks(); 1830 $(this).getParent('.siteevent_grid_footer').getElement('.siteevent_share_links').toggle(); 1831 1832 if(typeof val == 'undefined') { 1833 $(this).toggle(); 1834 } else { 1835 $(this).show(); 1836 } 1837 }); 1838} 1839 1840function showHideToggleShareLinks() { 1841 $$('.siteevent_share_links_toggle').show(); 1842 $$('.siteevent_share_links_toggle').getParent('.siteevent_grid_footer').getElement('.siteevent_share_links').hide(); 1843} 1844 1845function showReviewShareLinks(val) { 1846 $(document.body).addEvent('click', showHideToggleReviewShareLinks); 1847 $$('.sitereview_share_links_toggle').removeEvents('click').addEvent('click',function(event) { 1848 event.stop(); 1849 //showHideToggleShareLinks(); 1850 $(this).getParent('.sitereview_grid_footer').getElement('.sitereview_share_links').toggle(); 1851 1852 if(typeof val == 'undefined') { 1853 $(this).toggle(); 1854 } else { 1855 $(this).show(); 1856 } 1857 }); 1858} 1859 1860function showHideToggleReviewShareLinks() { 1861 $$('.sitereview_share_links_toggle').show(); 1862 $$('.sitereview_share_links_toggle').getParent('.sitereview_grid_footer').getElement('.sitereview_share_links').hide(); 1863} 1864 1865function showPageShareLinks(val) { 1866 $(document.body).addEvent('click', showHideTogglePageShareLinks); 1867 $$('.sitepage_share_links_toggle').removeEvents('click').addEvent('click',function(event) { 1868 event.stop(); 1869 //showHideToggleShareLinks(); 1870 $(this).getParent('.sitepage_grid_footer').getElement('.sitepage_share_links').toggle(); 1871 1872 if(typeof val == 'undefined') { 1873 $(this).toggle(); 1874 } else { 1875 $(this).show(); 1876 } 1877 }); 1878} 1879 1880function showHideTogglePageShareLinks() { 1881 $$('.sitepage_share_links_toggle').show(); 1882 $$('.sitepage_share_links_toggle').getParent('.sitepage_grid_footer').getElement('.sitepage_share_links').hide(); 1883} 1884 1885function showForumShareLinks(val) { 1886 $(document.body).addEvent('click', showForumHideToggleShareLinks); 1887 $$('.siteforum_share_links_toggle').removeEvents('click').addEvent('click',function(event) { 1888 event.stop(); 1889 //showHideToggleShareLinks(); 1890 $(this).getParent('.siteforum_grid_footer').getElement('.siteforum_share_links').toggle(); 1891 1892 if(typeof val == 'undefined') { 1893 $(this).toggle(); 1894 } else { 1895 $(this).show(); 1896 } 1897 }); 1898} 1899 1900function showForumHideToggleShareLinks() { 1901 $$('.siteforum_share_links_toggle').show(); 1902 $$('.siteforum_share_links_toggle').getParent('.siteforum_grid_footer').getElement('.siteforum_share_links').hide(); 1903} 1904 1905 1906function showGroupShareLinks(val) { 1907 $(document.body).addEvent('click', showHideToggleGroupShareLinks); 1908 $$('.sitegroup_share_links_toggle').removeEvents('click').addEvent('click',function(event) { 1909 event.stop(); 1910 //showHideToggleShareLinks(); 1911 $(this).getParent('.sitegroup_grid_footer').getElement('.sitegroup_share_links').toggle(); 1912 1913 if(typeof val == 'undefined') { 1914 $(this).toggle(); 1915 } else { 1916 $(this).show(); 1917 } 1918 }); 1919} 1920 1921function showHideToggleGroupShareLinks() { 1922 $$('.sitegroup_share_links_toggle').show(); 1923 $$('.sitegroup_share_links_toggle').getParent('.sitegroup_grid_footer').getElement('.sitegroup_share_links').hide(); 1924} 1925en4.seaocore.uploaderInstance = new Hash(); 1926var callbacks = {}; 1927en4.seaocore.initSeaoFancyUploaderQueue = { 1928 request: [], 1929 1930 add: function (params, callbacks) {
1931 this.request.push({params:params, callbacks: callbacks}); 1932 }, 1933 1934 trigger: function () { 1935 if (this.executing) 1936 return; 1937 this.executing = true; 1938 var data; 1939 while ((data = this.request.shift())) { 1940 en4.seaocore.initSeaoFancyUploader(data.params, data.callbacks); 1941 } 1942 this.request = []; 1943 this.executing = false; 1944 } 1945}; 1946en4.seaocore.initSeaoFancyUploader = function(params, callbacks) { 1947 if (typeof SeaoFancyUploader == 'undefined') { 1948 en4.seaocore.initSeaoFancyUploaderQueue.add(params, callbacks); 1949 if (en4.seaocore.initSeaoFancyUploaderQueue.request.lenght > 1) { 1950 return false; 1951 } 1952 options = {prependPath: en4.core.staticBaseUrl + 'externals/seao-fancy-uploader/'}; 1953 var self = this; 1954 loadDependingAssets = function() { 1955 self.loadAssets([{type: 'javascript', src: 'Uploader.HTML5.js'}], function() { 1956 en4.seaocore.initSeaoFancyUploaderQueue.trigger(); 1957 }, options ); 1958 } 1959 this.loadAssets([ 1960 {type: 'javascript', src: 'Request.Blob.js'}, 1961 {type: 'javascript', src: 'Uploader.js'}, 1962 {type: 'css', src: 'uploader.css'} 1963 ], loadDependingAssets, options); 1964 return false; 1965 } 1966 1967 var wrapper = $(params.name + '-wrapper'); 1968 var defaultParams = { 1969 ui_button: wrapper && wrapper.getElement('.upload-link'), 1970 ui_list: wrapper && wrapper.getElement('.uploaded-files-list'), 1971 ui_drop_area: wrapper && wrapper.getElement('.drop-area'), 1972 clear_list: wrapper && wrapper.getElement('.clear-list'), 1973 remote_input: wrapper && wrapper.getElement('input.remote-url'), 1974 remote_button: wrapper && wrapper.getElement('button.remote-fetch'), 1975 name: 'file', 1976 submitElement: true, 1977 responseParamId: 'photo_id', 1978 autosubmit: false, 1979 view: 'grid', 1980 debugMode: false, 1981 dropAreaClick: true, 1982 wrapperClass: '', 1983 populateFiles: {}, 1984 onActivate: function() { 1985 var self = this; 1986 this.debug = this.options.debugMode || en4.core.environment == 'development'; 1987 if (!this.options.autostart) { 1988 this.startUploadLink = wrapper.getElement('.start-upload-link'); 1989 this.startUploadLink.addEvent('click', function(event) { 1990 event.stop() 1991 self.upload(); 1992 event.target.hide(); 1993 }) 1994 } 1995 this.clearListLink = $(this.options.clear_list); 1996 if (this.clearListLink) { 1997 this.clearListLink.hide(); 1998 this.clearListLink.addEvent('click', function() { 1999 wrapper.getElements('.seao-fancy-uploader-item .file-remove, .file-error').each(function (link) { 2000 link.click(); 2001 }) 2002 if (self.submitWrapper) self.submitWrapper.hide(); 2003 self.progressBar.setStyle('width', '0px').set('html', ''); 2004 }) 2005 } 2006 2007 // HIDE DROP AREA AND REMOTE FILE WRAPPER ON CLICK OF UI BUTTON 2008 this.uiButton.addEvent('click', function() { 2009 if (self.uiButton != self.uiDropArea) self.uiDropArea.addClass('dnone'); 2010 self.remoteWrapper && self.remoteWrapper.addClass('dnone'); 2011 }); 2012 2013 // BIND CLICK EVENT TO DROP AREA 2014 if (this.uiDropArea) { 2015 if (wrapper.getElement('.drop-link')) { 2016 wrapper.getElement('.drop-link').addEvent('click', function() { 2017 self.uiDropArea.toggleClass('dnone'); 2018 if (self.remoteWrapper && !self.uiDropArea.hasClass('dnone')) { 2019 self.remoteWrapper.addClass('dnone'); 2020 } 2021 }); 2022 } 2023 if (this.options.dropAreaClick) { 2024 this.uiDropArea.addEvent('click', function(e) { 2025 e.stop(); this.lastInput.click(); 2026 }.bind(this)); 2027 } 2028 } 2029 2030 this.language = en4.core.language; 2031 this.limitFiles = this.options.multiple ? this.options.limitFiles : 1; 2032 this.paramId = this.options.responseParamId; 2033 this.submitWrapper = null; 2034 if ($(this.options.submitElement + '-wrapper')) { 2035 this.submitWrapper = $(this.options.submitElement + '-wrapper'); 2036 } 2037 2038 // ADD REQUIRED ERROR MESSAGES 2039 this.setErrorMessages();
2040 this.progressBar = wrapper.getElement('.progress-bar'); 2041 2042 // ADD CLASSES FOR VIEW - GRID / LIST / CAROUSEL 2043 this.view = this.options.view; 2044 this.uiList.addClass('uploader-' + this.view + '-view'); 2045 wrapper.addClass('seao-fancy-uploader-wrapper'); 2046 wrapper.addClass('uploader-' + this.view + '-view-wrapper'); 2047 wrapper.addClass(this.options.wrapperClass); 2048 2049 // INJECT FILE IDS ELEMENT IN FORM IF IT IS NOT IN FORM 2050 this.fileIdsElement = $(this.options.fileIdsElement) || wrapper.getElement('input.file-ids'); 2051 this.form = wrapper.getParent('form'); 2052 if (!this.form && (this.form = $(this.options.formId))) { 2053 this.fileIdsElement.inject(this.form); 2054 } 2055 2056 this.remoteLink = wrapper && wrapper.getElement('.remote-link'); 2057 this.remoteWrapper = wrapper && wrapper.getElement('.remote-wrapper'); 2058 if (this.remoteLink && this.remoteWrapper) { 2059 this.remoteLink.addEvent('click', function() { 2060 self.remoteWrapper.toggleClass('dnone'); 2061 if (self.uiDropArea && !self.remoteWrapper.hasClass('dnone')) { 2062 self.uiDropArea.addClass('dnone'); 2063 } 2064 }); 2065 this.remoteWrapper.getElement('.loading').hide(); 2066 } 2067 2068 // ADD SCROLLBAR TO UPLOADED FILE LIST 2069 this.scrollContainer = this.uiList.getParent('div.scrollbars'); 2070 this.maxHeight = {grid: 270, list: 400}; 2071 if (this.scrollContainer) { 2072 this.scrollContainer.setStyle('height', '0px'); 2073 this.scrollContainer.scrollbars({ 2074 scrollBarSize: 10, 2075 fade: true, 2076 barOverContent: true 2077 }); 2078 } 2079 2080 this.totalWidth = Math.min(this.getTotalWidth(), 400); 2081 this._log('onActivate'); 2082 this.fireEvent('onActivateCustom'); 2083 this._populateItems(); 2084 }, 2085 onAddFiles: function(num) { 2086 if (!num) return; 2087 if (!this.options.autostart) { 2088 this.startUploadLink.show(); 2089 } 2090 if (this.clearListLink) this.clearListLink.show(); 2091 }, 2092 onItemAdded: function(el, file, imagedata) { 2093 var self = this; 2094 el.addClass('uploader-file') 2095 .adopt(new Element('div', {'class': 'file-info-wrapper'}) 2096 .adopt(new Element('div', {'class': 'file-info'}) 2097 .adopt(new Element('span', {'class': 'file-name', 'title': file.name, 'html': file.name.truncate(60) })) 2098 .adopt(new Element('span', {'class': 'file-type', 'html': file.type})) 2099 .adopt(new Element('span', {'class': 'file-size', 'html': file.is_url ? '' : this._convertSize(file.size) })) 2100 ) 2101 .adopt(new Element('div', {'class': 'file-progress-list' }).set('tween', {duration: 200})) 2102 ) 2103 .adopt(new Element('div', {'class': 'file-preview'})) 2104 .adopt(new Element('div', {'class': 'file-progress'}).setStyle('left', 0)) 2105 .adopt(new Element('div', {'class': 'file-remove', 'title': this.language.translate('Remove')}).addEvent('click', function(e){e.stop(); self.cancel(file.id, el)})); 2106 2107 this.updateUiList(); 2108 this._log('onItemAdded - ' + file.name); 2109 if(!file.type) return; 2110 if(file.type.match('image') && imagedata){ 2111 el.addClass('image'); 2112 el.getElement('.file-preview').adopt(new Element('img', {'src': imagedata})); 2113 } else if (file.type.match('audio') || file.type.match('flac')){ 2114 el.addClass('audio'); 2115 } else if (file.type.match('video')){ 2116 el.addClass('video'); 2117 } 2118 }, 2119 // UPDATE SCROLL BARS 2120 onUpdateUiList: function() { 2121 if (!this.scrollContainer) return; 2122 var self = this; 2123 (function () { 2124 height = Math.min(self.maxHeight[self.view], self.uiList.getSize().y && self.uiList.getSize().y + 10); 2125 self.scrollContainer.setStyle('height', height + 'px'); 2126 self.scrollContainer.retrieve('scrollbars').updateScrollBars(); 2127 }).delay(50); 2128 }, 2129 onItemUploadStart: function(el, file) { 2130 el.addClass('file-uploading'); 2131 this._log('onItemUploadStart - ' + file.name); 2132 }, 2133 onItemProgress: function(el, perc) { 2134 el.getElement('.file-progress-list').tween('width', Math.round(this.getItemWidth() * perc/100)); 2135 el.getElement('.file-progress').setStyle('left', Math.floor(perc) + '%'); 2136 }, 2137 onItemComplete: function(el, file, response) { 2138 el.removeClass('file-uploading').addClass('file-success'); 2139 el.getElement('.file-progress-list').tween('width', this.getItemWidth()); 2140 el.getElement('.file-progress').setStyle('left', '100%'); 2141 el.set('data-file_id', response[this.paramId]); 2142 src = response['src'] || response['url'] || response['imgSrc']; 2143 src && el.getElement('.file-preview img').set('src', src); 2144 2145 value = this.fileIdsElement.get('value') + response[this.paramId] + ' '; 2146 this.fileIdsElement.set('value', value); 2147 2148 if (this.options.autosubmit && this._uploadedMaxFiles() && this.form) { 2149 typeof this.form.submit == 'function' ? this.form.submit() : this.form.submit.click(); 2150 } 2151 this._log('onItemComplete - ' + file.name); 2152 }, 2153 onItemCancel: function(el) { 2154 file_id = el.get('data-file_id'); 2155 el.destroy(); 2156 2157 if (this.uiList.getElements('.seao-fancy-uploader-item').length == 0) { 2158 if (this.clearListLink) this.clearListLink.hide(); 2159 if (!this.options.autostart) { 2160 this.startUploadLink.hide(); 2161 } 2162 } 2163 2164 if (!this._uploadedMaxFiles()) { 2165 this.uiButton.show(); 2166 this.lastInput.set('disabled', false); 2167 } 2168 2169 this.updateUiList(); 2170 if (!file_id) return; 2171 2172 if (this.fileIdsElement) { 2173 value = this.fileIdsElement.get('value').replace(file_id, ''); 2174 this.fileIdsElement.set('value', value); 2175 } 2176 2177 if (this.options.deleteUrl) { 2178 data = {}; 2179 data['isajax'] = 1; 2180 data[this.paramId] = file_id; 2181 request = new Request.JSON({ 2182 'format': 'json', 2183 'url': this.options.deleteUrl, 2184 'data': $merge(this.options.vars, data), 2185 'onSuccess': function (responseJSON) { 2186 return false; 2187 } 2188 }); 2189 request.send(); 2190 } 2191 this._log('onItemCancel'); 2192 }, 2193 onItemError: function(el, file, response) { 2194 el.removeClass('file-uploading').addClass('file-failed'); 2195 el.adopt(new Element('div', {class: 'file-error', html: response.error })); 2196 this._log('onItemError - ' + file.name ); 2197 }, 2198 onUploadStart: function() { 2199 if (!this.fileList.length) return; 2200 if (this.submitWrapper) this.submitWrapper.hide(); 2201 if (this.progressBar && !this.uploadingStatus) { 2202 this.uploadingStatus = true; 2203 this.progressBar.tween('width', 40); 2204 this.progressBar.set('html', '1%'); 2205 } 2206 this._log('onUploadStart'); 2207 }, 2208 onUploadProgress: function(perc) { 2209 if (!perc) return; 2210 this.progressBar.tween('width', this.getTotalWidth() * perc/100); 2211 this.progressBar.set('html', Math.floor(perc) + '%'); 2212 this._log('onUploadProgress - ' + Math.floor(perc) + '%' ); 2213 }, 2214 onUploadComplete: function(num) { 2215 if(num > 0) { 2216 this.progressBar.tween('width', this.getTotalWidth()); 2217 } else { 2218 this.progressBar.setStyle('width', 0); 2219 } 2220 if(this.lastInput) { 2221 this.lastInput.destroy(); 2222 } 2223 if (this.submitWrapper) this.submitWrapper.show(); 2224 this.uploadingStatus = this.isUploading; 2225 this._log('onUploadComplete: Uploaded Files - ' + num); 2226 }, 2227 onSelectError: function (type, filename, filesize) { 2228 errorMessage = this.getErrorMessage(type, filename, filesize); 2229 var uploadedFile = new Element('div', { 2230 'class': 'file-error', 2231 'html' : '<span class="validation-error" title="' + this.language.translate('Click to remove this entry.') + '">' + 'Error - ' + errorMessage + '</span>', 2232 events: { 2233 click: function() { 2234 this.destroy(); 2235 } 2236 } 2237 }).inject(this.uiList, 'before'); 2238 2239 if (type == 'limitFilesExceeded') { 2240 this.uiButton.hide(); 2241 this.lastInput.set('disabled', true); 2242 } 2243 }, 2244 onRemoteFetchStart: function(url) { 2245 this.remoteButton.hide(); 2246 if (!this.remoteWrapper) return; 2247 this.remoteWrapper.getElement('.error-message').hide(); 2248 this.remoteWrapper.getElement('.success-message').hide(); 2249 this.remoteWrapper.getElement('.loading').show(); 2250 this._log('onRemoteFetchStart - ' + url); 2251 }, 2252 onRemoteFetchComplete: function(url) { 2253 if (!this.remoteWrapper) return; 2254 this.remoteButton.show(); 2255 this.remoteWrapper.getElement('.success-message').show(); 2256 this.remoteWrapper.getElement('.loading').hide(); 2257 this._log('onRemoteFetchComplete - ' + url); 2258 }, 2259 onRemoteFetchError: function(type, url) { 2260 this.remoteButton.show(); 2261 if (!this.remoteWrapper) return; 2262 this.remoteWrapper.getElement('.loading').hide(); 2263 this.remoteWrapper.getElement('.error-message').show(); 2264 this.remoteWrapper.getElement('.error-message').set('html', this.language.translate(this.getErrorMessage(type))); 2265 this._log('onRemoteFetchError - ' + type); 2266 }, 2267 onItemPopulated: function(el, file) { 2268 file_id = file.id || file[this.responseParamId]; 2269 el.set('data-file_id', file_id); 2270 if (typeof file !== 'object') return; 2271 el.addClass('uploader-file file-success') 2272 .adopt(new Element('div', {'class': 'file-info-wrapper'}) 2273 .adopt(new Element('div', {'class': 'file-info'}) 2274 .adopt(new Element('span', {'class': 'file-name', 'title': file.name, 'html': file.name && file.name.truncate(60) })) 2275 )) 2276 .adopt(new Element('div', {'class': 'file-preview'})) 2277 .adopt(new Element('div', {'class': 'file-remove', 'title': this.language.translate('Remove')}).addEvent('click', function(e){e.stop(); self.cancel(file_id, el)})); 2278 2279 if (this.options.fileType === 'default' && file.src) { 2280 el.addClass('image'); 2281 el.getElement('.file-preview').adopt(new Element('img', {'src': file.src})); 2282 } else { 2283 el.addClass(this.options.fileType); 2284 } 2285 this._log('onItemPopulated - File id - ' + file_id); 2286 }, 2287 onPopulateFiles: function(num) { 2288 if (!num) return; 2289 if (this.clearListLink) this.clearListLink.show(); 2290 } 2291 }; 2292 params = $merge(defaultParams, params, callbacks); 2293 2294 uploader = new SeaoFancyUploader(params); 2295 this.uploaderInstance.set(params.name, uploader); 2296 return uploader; 2297}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.