1App['Anchor'] = function(o){ 2 var that = this, 3 config = cm.merge({ 4 'link' : cm.Node('a'), 5 'href' : null, 6 'target' : cm.Node('div'), 7 'scroll' : document.body, 8 'indentY' : 0, 9 'duration' : 800, 10 'setURL' : true 11 }, o), 12 anims = {}; 13 14 var init = function(){ 15 var y, styles; 16 // Init scroll animation 17 anims['scroll'] = new cm.Animation(config['scroll']); 18 // Add click event 19 cm.addEvent(config['link'], 'click', function(e){ 20 e = cm.getEvent(e); 21 cm.preventDefault(e); 22 // Set url 23 if(config['setURL'] && cm.isHistoryAPI && config['href']){ 24 window.history.pushState(false, false, config['href']); 25 } 26 // Get target position and animate to it 27 y = config['target'].offsetTop + config['indent']; 28 if(config['scroll'] == document.body){ 29 styles = {'docScrollTop' : y}; 30 }else{ 31 styles = {'scrollTop' : y}; 32 } 33 anims['scroll'].go({'style' : styles, 'anim' : 'smooth', 'duration' : config['duration']}); 34 }, true, true); 35 }; 36 37 /* ******* MAIN ******* */ 38 39 that.setIndent = function(indent){ 40 if(!isNaN(indent)){ 41 config['indent'] = indent 42 } 43 return that; 44 }; 45 46 init(); 47 48}; 49 50 51App['Event'] = function() { 52 var that = this, stack = {}; 53 that.add = function(element, event, handler) { 54 if (event) { 55 if (!stack[event]) { 56 stack[event] = []; 57 } 58 if (typeof handler === 'function') { 59 stack[event].push(handler); 60 } 61 } 62 return that; 63 }; 64 that.fire = function(element, event, details, context) { 65 if (event && stack[event]) { 66 cm.forEach(stack[event], function(handler) { 67 handler(details, context); 68 }); 69 } 70 return that; 71 } 72}; 73 74 75App['Request'] = function(opt) { 76 var that = this, config = cm.merge({ 77 'overlay' : true 78 }, opt), stack = {}; 79 that.send = function(url, params, method, context, options) { 80 if(!url || url===''){ 81 return; 82 } 83 var o = cm.merge(config, options); 84 if(o['overlay']){ 85 //open overlay 86 if (window.overlay) { 87 window.overlay.close(); 88 } 89 window.overlay = new Com.Overlay({'name':url}); 90 } 91 var async = true; 92 if(o['async']){ 93 async = o['async']; 94 } 95 96 var paramsType = "uri" 97 if(params instanceof FormData){ 98 paramsType = 'form-data'; 99 } 100 return cm.ajax({ 101 'async' : async, 102 'type': 'text', 103 'method': method, 104 'params': params, 105 'paramsType' : paramsType, 106 'url': url, 107 'onError' : function(respone, load) { 108 if (load && load.target.status === 403) { 109 window.location = window.config.url + "/user/login"; 110 } 111 //close overlay 112 if (window.overlay) { 113 var name = window.overlay.params.name; 114 if (name == url){ 115 window.overlay.close(); 116 } 117 } 118 }, 119 'onSuccess': function(respone, load) { 120 //close overlay 121 if (window.overlay) { 122 var name = window.overlay.params.name; 123 if (name == url){ 124 window.overlay.close(); 125 } 126 } 127 128 if (load.target.status === 200) { 129 var result = cm.parseJSON(respone); 130 if (result && result.result) { 131 cm.forEach(result.details, function(details, event) { 132 that.fire(event, details.details, context); 133 }); 134 } 135 } 136 } 137 }); 138 }; 139 that.add = function(event, handler) { 140 if (event) { 141 if (!stack[event]) { 142 stack[event] = []; 143 } 144 if (typeof handler === 'function') { 145 stack[event].push(handler); 146 } 147 } 148 return that; 149 }; 150 that.fire = function(event, details, context) { 151 if (event && stack[event]) { 152 cm.forEach(stack[event], function(handler) { 153 handler(details, context); 154 }); 155 } 156 return that; 157 } 158}; 159 160 161cm._assetsUrl = window.config.assets + 'lib/SerDIDG/MagpieUI'; 162App._assetsUrl = window.config.assets + 'lib/SerDIDG/QuickSilk-Application'; 163 164//language issue, double base url 165//cm._baseUrl = window.config.url; 166 167cm.getConstructor('Com.DateSelect', function(classConstructor, className, classProto){ 168 classProto.setParams({ 169 'endYear' : new Date().getFullYear() + 5 170 }); 171}); 172
173cm.getConstructor('App.Sidebar', function(classConstructor, className, classProto){ 174 classProto.setParams({ 175 'Com.TabsetHelper' : { 176 'cache' : true 177 } 178 }); 179}); 180 181 182 183 184/* ******* COMPONENTS CONFIGURATION ******* */ 185function formRequest(element, href, dialog, reload) { 186 if (!window.joverlay) { 187 window.joverlay = new Com.Overlay(); 188 } 189 $.getJSON(href, function (data) { 190 if (window.joverlay) { 191 window.joverlay.close(); 192 window.joverlay = null; 193 } 194 !function draw(data) { 195 if (!data.result && data.message) { 196 197 } else if (!data.details.form) { 198 if (reload) { 199 new Com.Overlay(); 200 window.location.reload(); 201 202 } 203 } else { 204 if (data.details.form) { 205 var node = cm.strToHTML(data.details.form.trim()); 206 var form = null; 207 if (-1 == node.tagName.toLowerCase().indexOf('form')) { 208 form = node.getElementsByTagName('form')[0]; 209 } else { 210 form = node; 211 } 212 213 $(form).on('form-submit-notify',function (data) { 214 if (!window.joverlay) { 215 window.joverlay = new Com.Overlay(); 216 } 217 }); 218 219 $(form).ajaxForm({ 220 'success': function (data) { 221 if (window.joverlay) { 222 window.joverlay.close(); 223 window.joverlay = null; 224 } 225 if (data.details.data && data.details.data.submit && !data.details.form) { 226 //save case 227 return; 228 } else { 229 //save and close case 230 cm.find('Com.Dialog', null, null, function (classObject) { 231 classObject.remove(); 232 }); 233 234 if (!data.details.form) { 235 if ('data' in data.details && 'goto-url' in data.details.data) { 236 window.location = data.details.data['goto-url']; 237 return; 238 } 239 240 if ('data' in data.details && 'window' in data.details.data) { 241 var winOpen = window.open(data.details.data['window']); 242 winOpen.focus(); 243 244 Request.fire('reload'); 245 return; 246 } 247 248 if (reload) { 249 new Com.Overlay(); 250 window.location.reload(); 251 return; 252 } 253 } 254 } 255 draw(data); 256 }, 257 'beforeSerialize': function () { 258 Collector.destruct(form); 259 } 260 }); 261 //get title for dialog 262 var title = node.getAttribute('title'); 263 node.removeAttribute('title'); 264 //form.removeAttribute('title'); 265 266 if (!dialog) { 267 //global 268 var dialog = new Com.Dialog({ 269 'id': 'activeElement', 270 'autoOpen': false, 271 'content': node, 272 'title': title, 273 'events': { 274 'onOpen': function () { 275 Collector.construct(node); 276 }, 277 'onClose': function () { 278 Collector.destruct(node); 279 } 280 } 281 }); 282 cm.customEvent.add(node, 'dialog-close', function (params) { 283 cm.find('Com.Dialog', null, null, function (classObject) { 284 classObject.remove(); 285 }); 286 }); 287 } else { 288 dialog.set(title, node); 289 } 290 dialog.open(); 291 } 292 } 293 }(data); 294 }); 295} 296/* ******* GLOBAL COLLECTORS ******* */ 297 298(function ($) { 299 window.AppEvent = new App.Event(); 300 window.Request = new App.Request(); 301 window.Collector = new Com.Collector(); 302 303 // //deprecated 304 $(document).bind('ajaxError', function (event, jqxhr) { 305 if (jqxhr.status == 403) { 306 window.location = window.config.url + "/user/login"; 307 } 308 }); 309 310 Request.add('dialog', function (details, context) { 311 //create new or select existing dialog 312 var content = cm.strToHTML(details['content']); 313 Collector.construct(content); 314 315 /* 316 var content = '' , 317 result = false;
318 319 // case for text content 320 try { 321 content = cm.strToHTML(details['content']); 322 Collector.construct(content); 323 result = true; 324 } catch (e){ 325 //console.log(e) 326 } 327 328 // case for html content 329 if (!result){ 330 content = '<div>' + details['content'] + '</div>'; 331 content = cm.strToHTML(content); 332 Collector.construct(content); 333 }*/ 334 335 var dialog = new Com.Dialog({ 336 'content': content, 337 'events': { 338 'onOpen': function () { 339 cm.customEvent.add(content, 'dialog-close', function (params) { 340 cm.find('Com.Dialog', null, null, function (classObject) { 341 classObject.remove(); 342 }); 343 }); 344 AppEvent.fire(document, 'dialog-open', {'dialog': dialog, 'name': details['name']}); 345 }, 346 'onOpenStart': function () { 347 Collector.construct(content); 348 }, 349 'onClose': function () { 350 Collector.destruct(content); 351 AppEvent.fire(document, 'dialog-close', {'dialog': dialog, 'name': details['name']}); 352 if( details['reload'] ){ 353 Request.fire('reload'); 354 } 355 } 356 } 357 }); 358 if (details['title']) { 359 dialog.setTitle(details['title']) 360 } else { 361 var title = content.getAttribute('title'); 362 if (title) { 363 dialog.setTitle(title); 364 } 365 } 366 }); 367 368 Request.add('ajax-form', function (details, context) { 369 var content = cm.strToHTML(details['content']); 370 cm.replaceNode(content, context['node']); 371 Collector.construct(content); 372 }); 373 374 Request.add('form', function (details, context) { 375 var content = cm.strToHTML(details['content']); 376 377 378 var form = content.getElementsByTagName('form'); 379 form = (form.length === 0) ? content : form[0]; 380 381 if (context && context['data']) { 382 cm.forEach(context['data'], function (value, name) { 383 if ('csrf' == name.substr(0, 4)) { 384 delete context['data'][name]; 385 } 386 }); 387 cm.setFDO(context['data'], form); 388 } 389 390 var dialog = false; 391 if (context && context['dialog']) { 392 dialog = context['dialog']; 393 dialog.setContent(content); 394 dialog.setTitle(content.getAttribute('title')); 395 Collector.construct(content); 396 cm.customEvent.add(content, 'dialog-close', function (params) { 397 cm.find('Com.Dialog', null, null, function (classObject) { 398 classObject.remove(); 399 }); 400 }); 401 } else { 402 var params = { 403 'content': content, 404 'title': content.getAttribute('title'), 405 'events': { 406 'onOpenStart': function () { 407 Collector.construct(content); 408 }, 409 'onOpen': function () { 410 cm.customEvent.add(content, 'dialog-close', function (params) { 411 cm.find('Com.Dialog', null, null, function (classObject) { 412 classObject.remove(); 413 }); 414 }); 415 AppEvent.fire(document, 'dialog-open', {'dialog': dialog, 'name': details['name']}); 416 }, 417 'onClose': function () { 418 Collector.destruct(content); 419 AppEvent.fire(document, 'dialog-close', {'dialog': dialog, 'name': details['name']}); 420 } 421 } 422 }; 423 if (details['params']) { 424 params = cm.merge(params, details['params']) 425 } 426 dialog = new Com.Dialog(params); 427 } 428 429 cm.addEvent(form, 'submit', function (e) { 430 Collector.destruct(form); 431 context = cm.extend(context, {'form': form, 'dialog': dialog, 'name': details['name']}); 432 Request.send(form.getAttribute('action'), cm.getFDO(form), 'post', context); 433 cm.preventDefault(e); 434 }); 435 }); 436 437 Request.add('form-close', function (details, context) { 438 if (context && context['dialog']) { 439 context['dialog'].close(); 440 if (context['opener']) { 441 var content = context['opener'].getNodes('inner'); 442 var form = content.getElementsByTagName('form'); 443 var url = form[0].getAttribute('action'); 444 Collector.destruct(content); 445 Request.send(url, {}, 'get', { 446 'data': cm.getFDO(form[0]), 447 'dialog': context['opener'] 448 }, {'overlay': false}); 449 } else { 450 if ('data' in details && 'goto-url' in details.data) { 451 window.location = details.data['goto-url']; 452 453 } 454 } 455 } 456 }); 457 458 Request.add('redirect', function (details, context) { 459 if (context && context['dialog']) { 460 context['dialog'].close(); 461 } 462 if (!window.joverlay) { 463 window.joverlay = new Com.Overlay(); 464 } 465 location.href = details['url']; 466 }); 467 468 Request.add('reload', function (details, context) { 469 if (context && context['dialog']) { 470 context['dialog'].close(); 471 } 472 473 new Com.Overlay(); 474 if (context && context['node'] && context['node'].getAttribute('data-back')) { 475 var node = context['node']; 476 var back = node.getAttribute('data-back'); 477 if (back == 'history.back') { 478 history.back(-1); 479 } else { 480 var target = node.getAttribute('data-back-target'); 481 if (target) { 482 window.open(back, target); 483 } else { 484 location = back; 485 } 486 } 487 } else { 488 location.reload(true); 489 } 490 }); 491 492 Request.add('printinvoice', function (details, context) { 493 var childWindow = window.open('', 'childWindow', 'location=yes, menubar=yes, toolbar=yes'); 494 if(childWindow){ 495 return; 496 //childWindow.document.open(); 497 childWindow.document.write(details.content); 498 childWindow.document.close(); 499 childWindow.focus(); 500 childWindow.print(); 501 setTimeout(function () { childWindow.close(); }, 100); 502 } 503 }); 504 505 Request.add('download', function (details, context) { 506 var parent = document.body;
507 var overlay = new Com.Overlay({ 508 autoOpen: true, 509 lazy: false 510 }); 511 512 // Kill all previous iframes 513 var frames = parent.getElementsByTagName('iframe'); 514 if(!!frames && 0 < frames.length){ 515 for(var i = 0; i < frames.length; i++){ 516 cm.remove(frames[i]); 517 } 518 } 519 // Render iframe 520 var url = details.url; 521 var frame = cm.node('iframe', { 522 'style' : 'width:0; height:0; display:none; border:0px;', 523 'class' : 'iframe-ghost', 524 'src' : url 525 }); 526 cm.appendChild(frame, parent); 527 528 setTimeout(function(){ 529 overlay.close() 530 }, 3000); 531 532 cm.addEvent(frame, 'load', function(e){ 533 if (overlay) { 534 overlay.close(); 535 } 536 setTimeout(function(){ 537 cm.remove(frame); 538 }, 350); 539 }); 540 541 542 // Kill overlay if something goes wrong 543 setTimeout(function(){ 544 if (overlay) { 545 overlay.close(); 546 } 547 }, 600000);// 10 min 548 }); 549 550 Collector.add('ajax-form', function (node) { 551 var form = node.getElementsByTagName('form')[0] || node; 552 if(form){ 553 cm.addEvent(form, 'submit', function (e) { 554 Collector.destruct(node); 555 Request.send(form.getAttribute('action'), new FormData(form), 'post', {'node': node}); 556 cm.preventDefault(e); 557 }); 558 cm.addEvent(form, 'reset', function (e) { 559 Collector.destruct(node); 560 Request.send(form.getAttribute('action'), {}, 'get', {'node': node}); 561 cm.preventDefault(e); 562 }); 563 } 564 }); 565 Collector.add('ajax-download', function (node) { 566 cm.addEvent(node, 'click', function (e) { 567 Request.fire('download', {url: node.getAttribute('href')}); 568 cm.preventDefault(e); 569 }); 570 }); 571 Collector.add('activenew', function (node) { 572 cm.addEvent(node, 'click', function (e) { 573 var url = e.currentTarget.getAttribute('data-url'); 574 if (!url) { 575 url = e.currentTarget.getAttribute('href'); 576 } 577 if (url) { 578 Request.send(url, {}, 'get', {'node': node}); 579 cm.preventDefault(e); 580 } 581 }, true, true); 582 }); 583 Collector.add('url', function (node) { 584 cm.addEvent(node, 'click', function (e) { 585 var url = e.currentTarget.getAttribute('data-url'); 586 if (!url) { 587 url = e.currentTarget.getAttribute('href'); 588 } 589 if (url) { 590 location.href = url; 591 cm.preventDefault(e); 592 } 593 }, true, true); 594 }); 595 //deprecated 596 Collector.add('active', function (node) { 597 cm.addEvent(node, 'click', function (e) { 598 var url = e.currentTarget.getAttribute('data-url'); 599 if (!url) { 600 url = e.currentTarget.getAttribute('href'); 601 } 602 if (url) { 603 formRequest(this, url, null, e.currentTarget.getAttribute('data-disable-reload') == undefined); 604 cm.preventDefault(e); 605 } 606 }, true, true); 607 }); 608 609 //deprecated 610 Collector.add('dialog-close', function (node) { 611 cm.addEvent(node, 'click', function (e) { 612 var goto = e.currentTarget.getAttribute('data-goto'); 613 if (goto) { 614 if (goto == 'history.back') { 615 history.back(-1); 616 } else { 617 var target = e.currentTarget.getAttribute('data-target'); 618 if (target) { 619 window.open(goto, target); 620 } else { 621 location = goto; 622 } 623 } 624 } 625 cm.customEvent.trigger(node, 'dialog-close'); 626 cm.preventDefault(e); 627 }, true, true); 628 }); 629 630 Collector.add('flash-message-close', function (node) { 631 cm.addEvent(node, 'click', function (e) { 632 node.parentNode.style.display = 'none'; 633 cm.preventDefault(e); 634 }); 635 }); 636 Collector.add('app-helptour', function (node) { 637 new App.HelpTour({ 638 'node': node 639 }); 640 }, null, 2000); 641 642 Collector.add('select', function (node) { 643 node.removeAttribute('data-element'); 644 if ('autocompletefield' == node.getAttribute('data-sub-element')){ 645 new Com.AutocompleteField({'node': node}); 646 } else { 647 var select = new Com.Select({'select': node}); 648 var id = (node.id ? node.id : node.name); 649 if (id) { 650 Com.Elements.Selects[id] = select; 651 } 652 } 653 }); 654 655 Collector.add('linked-select', function (node) { 656 var nodes = cm.getNodes(node); 657 cm.forEach(nodes['linked-button'], function (item, key) { 658 cm.addEvent(item['button'], 'click', function (e) { 659 var url = e.currentTarget.getAttribute('data-url'); 660 if (url) { 661 if (window.dialogstack) { 662 var context = {'opener': window.dialogstack.slice(-1)[0]}; 663 Request.send(url.replace(/%id%|%25id%25/gi, select.get()), {}, 'get', context); 664 } else { 665 // Use the Post/Redirect/Get (PRG) pattern 666 // @see https://en.wikipedia.org/wiki/Post/Redirect/Get 667 location = location.href; 668 } 669 } 670 cm.preventDefault(e); 671 }); 672 }); 673 function onSelect(select, active) { 674 cm.forEach(nodes['linked-button'], function (item, key) { 675 if (item['button'].getAttribute('data-name') !== 'add') { 676 if (cm.isEmpty(active)) { 677 item['button'].style.display = 'none'; 678 } else { 679 item['button'].style.display = ''; 680 } 681 } 682 }); 683 } 684 var select = Com.GetSelect(node.getAttribute('data-name')); 685 if (select) { 686 select.addEvent('onSelect', onSelect); 687 onSelect(select, select.get()); 688 } 689 }); 690 691 Collector.add('tabset', function (node) { 692 var options = { 693 'node' : node, 694 'useCookie': true, 695 'params': {}, 696 'events' : { 697 'onTabShow' : function(that, data){ 698 if (data.url){ 699 Request.send(data.url, {}, 'get', {'id': that.params['name']}, {'overlay': true}); 700 } 701 if(that.params['useCookie']){ 702 cm.storageSet('tabset_'+that.params['name'], data.id, true); 703 }else{ 704 cm.storageRemove('tabset_'+that.params['name'], true); 705 } 706 }, 707 } 708 }; 709 var params = node.getAttribute('data-config'); 710 params = cm.parseJSON(params); 711 if (params) { 712 options = cm.merge(options, params); 713 } 714 var id = node.getAttribute('data-tabset-id'); 715 if (id) { 716 options['name'] = id; 717 } 718 if(options['useCookie']){ 719 var active = cm.storageGet('tabset_'+options['name'], true); 720 if(active){ 721 options['active'] = active; 722 options['toggleOnHashChange'] = false;
723 } 724 } 725 new Com.Tabset(options); 726 }); 727 728 729 Request.add('insert-form', function(details, context) { 730 // Get tabset by id 731 new cm.Finder('Com.Tabset', context.id, null, function(classObject) { 732 var active = classObject.getActiveTab(); 733 active.content.innerHTML = details.content; 734 Collector.construct(active.content); 735 }); 736 737 }); 738 739 Collector.add('tagsinput', function (node) { 740 var params = {'node': node}; 741 var text = node.getAttribute('data-text'); 742 if (text) { 743 params['langs'] = {'placeholder': text}; 744 } 745 new Com.TagsInput(params); 746 }); 747 748 Collector.add('datePicker', function (node) { 749 var options = { 750 'node' : node, 751 'isDateTime' : true, 752 'setEmptyDateByFormat' : false, 753 'dateTimeFormat' : '%Y-%m-%d %H:%i:%s', 754 'displayDateTimeFormat' : '%F %j, %Y, %H:%i' 755 }; 756 var params = node.getAttribute('data-config'); 757 params = cm.parseJSON(params); 758 if (params) { 759 options = cm.merge(options, params); 760 } 761 if (params && 'select' == params.type) { 762 new Com.DateSelect(options); 763 }else{ 764 new Com.Datepicker(options); 765 } 766 }); 767 768 Collector.add('timepicker', function (node) { 769 new Com.TimeSelect({ 770 'node' : node 771 }); 772 }); 773 774 Collector.add('colorpicker', function (node) { 775 new Com.ColorPicker({ 776 'node': node 777 }); 778 }); 779 780 Collector.add('dateSelect', function (node) { 781 new Com.DateSelect({ 782 'node': node 783 }); 784 }); 785 786 Collector.add('togglebox', function (node) { 787 new Com.ToggleBox({ 788 'node': node 789 }); 790 }); 791 792 Collector.add('gridlist', function (node) { 793 new Com.ToggleBoxGridlist({ 794 'node': node, 795 'useLangs': true, 796 'langs': { 797 'showTitle': node.getAttribute('data-togglebox-show'), 798 'hideTitle': node.getAttribute('data-togglebox-hide') 799 } 800 }); 801 }); 802 803 Collector.add('gridlist-helper', function (node) { 804 new Com.GridlistHelper({'node': node, 'columns': { 805 'ajax': { 806 'url': node.getAttribute('data-partial-url'), 807 'params': {'params': '%items%'} 808 } 809 }}); 810 }); 811 812 Collector.add('autocomplete', function (node) { 813 var options = { 814 'input': node, 815 'clearOnEmpty': false, 816 'data': [] 817 }; 818 819 var params = node.getAttribute('data-config'); 820 params = cm.parseJSON(params); 821 if (params) { 822 options = cm.merge(options, params); 823 } 824 new Com.Autocomplete(options); 825 }); 826 827 Collector.add('multifield', function (node) { 828 new Com.MultiField({ 829 'node': node, 830 'events': { 831 'onItemAdd': function (that, item) { 832 Collector.construct(item['field']); 833 } 834 } 835 }); 836 }); 837 838 Collector.add('fieldset', function (node) { 839 var remove = function (e) { 840 cm.remove(this.parentNode.parentNode); 841 var rows = cm.getByClass('form-multifield-line', node); 842 cm.forEach(rows, function (item, idx) { 843 var replace = function (item) { 844 item.name = item.name.replace(/(\[[0-9]*\])/g, "[" + (idx - 1) + "]"); 845 }; 846 var inputs = item.getElementsByTagName('input'); 847 cm.forEach(inputs, replace); 848 var selects = item.getElementsByTagName('select'); 849 cm.forEach(selects, replace); 850 node.setAttribute('data-idx', idx); 851 }); 852 853 cm.preventDefault(e); 854 }; 855 var add = function (e) { 856 var str = this.getAttribute('data-template'); 857 var idx = node.getAttribute('data-idx'); 858 str = str.replace(/(__index__)/g, isNaN(idx) ? 0 : idx); 859 node.setAttribute('data-idx', ++idx); 860 this.setAttribute('data-idx', ++idx); 861 // node.setAttribute('data-template', str); 862 863 var template = cm.node('div', {'innerHTML': str}); 864 var row = template.firstChild; 865 cm.insertBefore(row, this.parentNode.parentNode); 866 //add remove button event 867 var buttons = cm.getByAttr('data-button', 'remove', row); 868 cm.forEach(buttons, function (button) { 869 cm.addEvent(button, 'click', remove); 870 }); 871 //build components 872 Collector.construct(row); 873 //node.setAttribute('data-idx', node.getAttribute('data-idx')++); 874 cm.preventDefault(e); 875 }; 876 var buttons = cm.getByAttr('data-button', 'remove', node); 877 cm.forEach(buttons, function (button) { 878 cm.addEvent(button, 'click', remove); 879 }); 880 node.setAttribute('data-idx', buttons.length); 881 var buttons = cm.getByAttr('data-button', 'add', node); 882 cm.forEach(buttons, function (button) {
883 cm.addEvent(button, 'click', add); 884 }); 885 }); 886 887 Collector.add('calendar', function (node) { 888 new Com.CalendarEvents({'node': node}); 889 }); 890 891 Collector.add('publishingstatus-unveil', function (node) { 892 var options = {}; 893 var params = node.getAttribute('data-config'); 894 if (params) { 895 options = cm.merge(options, JSON.parse(params)); 896 } 897 var hendler = function (classObject) { 898 var publishing = classObject; 899 publishing.addEvent('onChange', function(element, value) { 900 var nodes = cm.getNodes(); 901 if ('always' == value) { 902 cm.addClass(nodes['AppForm']['startpublishing'], 'display-none'); 903 cm.addClass(nodes['AppForm']['stoppublishing'], 'display-none'); 904 } else { 905 cm.removeClass(nodes['AppForm']['startpublishing'], 'display-none'); 906 cm.removeClass(nodes['AppForm']['stoppublishing'], 'display-none'); 907 } 908 }); 909 publishing.triggerEvent('onChange', publishing.get()); 910 }; 911 new cm.Finder('Com.Select', 'publishingstatus', node, hendler); 912 new cm.Finder('Com.Select', 'general[publishingstatus]', node, hendler); 913 }); 914 915 /*Show/Hide Elements by radio button value*/ 916 Collector.add('radio-unveil', function (node) { 917 var options = {}; 918 var params = node.getAttribute('data-config'); 919 if (params) { 920 options = cm.merge(options, JSON.parse(params)); 921 } 922 var nodes = cm.getNodes(); 923 cm.forEach(options.elements, function(elements, key){ 924 var option = node.querySelectorAll('[value="'+key+'"]'); 925 cm.forEach(option, function(element){ 926 var id = element.getAttribute('id'); 927 var label = node.querySelectorAll('[for="'+id+'"]'); 928 cm.forEach(options.elements[key],function(element){ 929 var result = nodes; 930 cm.forEach(element.split('.'),function(path){ 931 result = result[path]; 932 }); 933 var target = cm.strToHTML(options.template); 934 cm.appendChild(result, target); 935 cm.insertAfter(target, label[0]); 936 }); 937 }); 938 }); 939 }); 940 941 //deprecated 942 Collector.add('gridlist-togglebox', function (node) { 943 new Com.ToggleBoxGridlist({ 944 'node': node, 945 'useLangs': true, 946 'langs': { 947 'showTitle': 'View', 948 'hideTitle': 'Hide' 949 } 950 }); 951 }); 952 953 Collector.add('gallery-popup', function (node) { 954 new Com.GalleryPopup({'node': node}); 955 }); 956 957 Collector.add('dynamical-default-pagination', function (node) { 958 new Com.Pagination({ 959 'node': node, 960 'responseHTML': true, 961 'events': { 962 'onPageRenderEnd': function (that, page) { 963 // Construct components 964 window.Collector.construct(page['container']); 965 } 966 }, 967 'ajax': { 968 'type': 'json', 969 'params': { 970 'page': '%page%' 971 } 972 } 973 }); 974 }); 975 976 Collector.add('dynamical-scroll-pagination', function (node) { 977 new Com.ScrollPagination({ 978 'node': node, 979 'showButton': 'once', 980 'responseHTML': true, 981 'events': { 982 'onPageRenderEnd': function (that, page) { 983 // Construct components 984 window.Collector.construct(page['container']); 985 } 986 }, 987 'ajax': { 988 'type': 'json', 989 'params': { 990 'page': '%page%' 991 } 992 } 993 }); 994 }); 995 996 Collector.add('help-bubble', function (node) { 997 new Com.HelpBubble({'node': node}); 998 }); 999 1000 Collector.add('box-tools', function(node) { 1001 new Com.BoxTools({'node' : node}); 1002 }); 1003 1004 Collector.add('box-radius-tools', function(node) { 1005 new Com.BoxRadiusTools({'node':node}); 1006 }); 1007 1008 Collector.add('app-formstyles', function (node) { 1009 new App.FormStyles( {'node': node}); 1010 }); 1011 1012 Collector.add('position-tools', function (node) { 1013 new Com.PositionTools({'node': node}); 1014 }); 1015 1016 Collector.add('range', function (node) { 1017 new Com.Range({'node': node}); 1018 }); 1019 1020 Collector.add('repeat-tools', function (node) { 1021 new Com.RepeatTools({'node': node}); 1022 }); 1023 1024 Collector.add('scale-tools', function (node) { 1025 new Com.ScaleTools({'node': node}); 1026 }); 1027 1028 Collector.add('indent-input', function (node) { 1029 new Com.IndentInput({'node': node}); 1030 }); 1031 1032 Collector.add('integer-input', function (node) { 1033 new Com.IntegerInput({'node': node}); 1034 }); 1035 1036 Collector.add('app-fontinput', function (node) { 1037 new App.FontInput({'node': node}); 1038 }); 1039 Collector.add('check-trigger', function (node) { 1040 new Com.CheckTrigger({'node': node}); 1041 }); 1042 1043 Collector.add('tabset-helper', function (node) { 1044 new Com.TabsetHelper({'node':node}); 1045 }); 1046 1047 Collector.add('two-side-multi-select', function (node) { 1048 new Com.TwoSideMultiSelect({'node': node}); 1049 }); 1050 1051// Collector.add('app.panel-holder', function(node) { 1052// new App.PanelContainer({'node':node}); 1053// }); 1054// 1055// Collector.add('app.panel-request', function(node) { 1056// new App.PanelContainer({'node':node}); 1057// }); 1058 1059 Collector.add('app.panel-container', function(node) { 1060 new App.PanelContainer({'node':node}); 1061 }); 1062 1063 Collector.add('app-notification', function (node) { 1064 new App.Notification({'node': node}); 1065 }); 1066 1067 cm.onReady(function () { 1068 // Useragent 1069 Com.UA.setBrowserClass(); 1070 1071 //build components 1072 Collector.construct(); 1073 1074 AppEvent.add(document, 'dialog-open', function (details, context) { 1075 if (window.dialogstack == undefined) { 1076 window.dialogstack = []; 1077 }
1078 window.dialogstack.push(details['dialog']); 1079 }); 1080 AppEvent.add(document, 'dialog-close', function (details, context) { 1081 window.dialogstack.pop(); 1082 }); 1083 }); 1084 1085})(window.jQuery); 1086 1087/* ******* GALERIES CONFIG ******* */ 1088 1089cm.define('App.ModuleImageGallery', { 1090 extend: 'App.AbstractModule', 1091 params: { 1092 renderStructure: false, 1093 embedStructureOnRender: false, 1094 type: 'default', // default | tiles 1095 popup: true, 1096 navigation: false, 1097 count: 0, 1098 perPage: 0, 1099 }, 1100}, 1101function() { 1102 App.AbstractModule.apply(this, arguments); 1103}); 1104 1105cm.getConstructor('App.ModuleImageGallery', function(classConstructor, className, classProto, classInherit) { 1106 classProto.onConstructStart = function() { 1107 var that = this; 1108 1109 // Variables 1110 that.popupRequestCallback = null; 1111 that.pages = []; 1112 }; 1113 1114 classProto.onValidateParams = function() { 1115 var that = this; 1116 that.params.count = parseInt(that.params.count); 1117 that.params.perPage = parseInt(that.params.perPage); 1118 }; 1119 1120 classProto.renderViewModel = function() { 1121 var that = this; 1122 1123 // Call parent method 1124 classInherit.prototype.renderViewModel.apply(that, arguments); 1125 1126 // Init pagination 1127 new cm.Finder('Com.ScrollPagination', that.params.name, that.params.node, function(classObject) { 1128 that.components.pagination = classObject; 1129 that.components.pagination.addEvent('onPageRenderEnd', that.processPage.bind(that)); 1130 }); 1131 new cm.Finder('Com.Pagination', that.params.name, that.params.node, function(classObject) { 1132 that.components.pagination = classObject; 1133 that.components.pagination.addEvent('onPageRenderEnd', that.processPage.bind(that)); 1134 }); 1135 new cm.Finder('Com.GalleryPopup', that.params.name, that.params.node, function(classObject) { 1136 that.components.popup = classObject; 1137 if (that.params.navigation) { 1138 that.components.gallery = that.components.popup.getGallery(); 1139 that.components.gallery.setParams({ 1140 navigation: { 1141 enable: false, 1142 cycle: false, 1143 count: that.params.count, 1144 }, 1145 }); 1146 that.components.popup.addEvent('onPrev', that.requestPrevItem.bind(that)); 1147 that.components.popup.addEvent('onNext', that.requestNextItem.bind(that)); 1148 } 1149 }); 1150 }; 1151 1152 classProto.processPage = function(pagination, data) { 1153 var that = this, 1154 nodes = that.getDataNodesObject(data.container, that.params.nodesDataMarker, false), 1155 itemsLength = nodes.items ? nodes.items.length : 0; 1156 1157 // Add to array 1158 that.pages[data.page] = data; 1159 1160 // Add to gallery 1161 if (that.params.popup && that.components.popup) { 1162 that.components.popup.collect(data.container, { 1163 fromIndex: (data.page - 1) * that.params.perPage, 1164 fromPage: data.page, 1165 }); 1166 if (that.popupRequestCallback) { 1167 cm.isFunction(that.popupRequestCallback) && that.popupRequestCallback(); 1168 that.popupRequestCallback = null; 1169 } 1170 } 1171 1172 // Process tiles items 1173 if (that.params.type === 'tiles') { 1174 that.processItems(nodes); 1175 } 1176 1177 // Finalize scroll pagination 1178 if (!itemsLength) { 1179 cm.isFunction(that.components.pagination.finalize) && that.components.pagination.finalize(); 1180 } 1181 }; 1182 1183 classProto.processItems = function(nodes) { 1184 var that = this, 1185 itemsLength = nodes.items ? nodes.items.length : 0, 1186 rowI = 0, 1187 row; 1188 1189 // Process items 1190 cm.forEach(nodes.items, function(item, i) { 1191 // Start row 1192 rowI++; 1193 if (rowI === 1) { 1194 row = { 1195 items: [], 1196 width: 0 1197 }; 1198 } 1199 1200 // Render item 1201 that.processItem(item); 1202 row.width += item._config.normalizedWidth; 1203 row.items.push(item); 1204 1205 // End row 1206 if (rowI >= that.params.columns || i === (itemsLength - 1)) { 1207 // Empty tiles 1208 if (row.items.length < that.params.columns) { 1209 row.width += 134 * (that.params.columns - row.items.length); 1210 } 1211 1212 // Calculate item widths 1213 cm.forEach(row.items, function(rowItem) { 1214 that.setItemWidth(rowItem, row.width); 1215 }); 1216 rowI = 0; 1217 } 1218 }); 1219 }; 1220 1221 classProto.processItem = function(item) { 1222 var that = this; 1223 1224 // Get config 1225 item._config = that.getNodeDataConfig(item.container); 1226 item._config.aspectRatio = item._config.width / item._config.height; 1227 item._config.aspectHeight = 100 / item._config.aspectRatio; 1228 item._config.normalizedWidth = item._config.aspectRatio * 100; 1229 item._config.image = item.image.getAttribute('src'); 1230 1231 // Image 1232 item.descr = cm.node('div', {classes: 'descr'}); 1233 item.descr.style.paddingBottom = item._config.aspectHeight + '%'; 1234 item.descr.style.backgroundImage = cm.URLToCSSURL(item._config.image); 1235 cm.insertAfter(item.descr, item.image); 1236 cm.remove(item.image); 1237 1238 // Load 1239 cm.onImageLoad(item._config.image, function() { 1240 cm.addClass(item.link, 'is-loaded', true); 1241 }); 1242 }; 1243 1244 classProto.setItemWidth = function(item, rowWidth) { 1245 var that = this, 1246 newWidth = 100 / rowWidth * item._config.normalizedWidth; 1247 item.container.style.width = newWidth + '%'; 1248 }; 1249 1250 classProto.requestPrevItem = function(popup, data) { 1251 var that = this; 1252 var index = data.index - 1; 1253 var page = Math.floor(index / that.params.perPage) + 1; 1254 1255 if (index < 0) { 1256 return; 1257 } 1258 1259 if (cm.isInstance(that.components.pagination, 'Com.Pagination')) { 1260 if (!that.pages[page] || !that.pages[page].isRendered) { 1261 that.popupRequestCallback = function() { 1262 that.requestPrevItem(popup, data); 1263 }; 1264 popup.toggleLoader(true); 1265 that.components.pagination.set(page); 1266 } else { 1267 that.components.pagination.set(page); 1268 popup.set(index); 1269 } 1270 } else if (cm.isInstance(that.components.pagination, 'Com.ScrollPagination')) { 1271 popup.set(index); 1272 } else { 1273 popup.close(); 1274 } 1275 }; 1276 1277 classProto.requestNextItem = function(popup, data) { 1278 var that = this; 1279 var index = data.index + 1; 1280 var page = Math.floor(index / that.params.perPage) + 1; 1281 1282 if (index >= popup.getCount()) { 1283 return; 1284 } 1285 1286 if (cm.isInstance(that.components.pagination, 'Com.Pagination')) { 1287 if (!that.pages[page] || !that.pages[page].isRendered) { 1288 that.popupRequestCallback = function() { 1289 that.requestNextItem(popup, data); 1290 }; 1291 popup.toggleLoader(true); 1292 that.components.pagination.set(page); 1293 } else { 1294 that.components.pagination.set(page); 1295 popup.set(index); 1296 } 1297 } else if (cm.isInstance(that.components.pagination, 'Com.ScrollPagination')) { 1298 if (index < popup.getLength()) { 1299 popup.set(index); 1300 } else if (index < popup.getCount()) { 1301 that.popupRequestCallback = function() { 1302 that.requestNextItem(popup, data); 1303 }; 1304 popup.toggleLoader(true); 1305 that.components.pagination.set(); 1306 } 1307 } else { 1308 popup.close(); 1309 } 1310 }; 1311}); 1312 1313cm.define('App.FormImageGalery', { 1314 extend: 'Com.AbstractController', 1315 params: { 1316 renderStructure: false, 1317 embedStructureOnRender: false 1318 } 1319}, 1320function() { 1321 Com.AbstractController.apply(this, arguments); 1322}); 1323
1324cm.getConstructor('App.FormImageGalery', function(classConstructor, className, classProto, classInherit){ 1325 classProto.renderViewModel = function(){ 1326 var that = this; 1327 // Call parent method 1328 classInherit.prototype.renderViewModel.apply(that, arguments); 1329 // Get components 1330 cm.find('Com.Select', 'general[style]', that.params['node'], function(classObject){ 1331 that.components['style'] = classObject; 1332 }); 1333 cm.find('Com.Select', 'style', that.params['node'], function(classObject){ 1334 that.components['style'] = classObject; 1335 }); 1336 cm.find('Com.Select', 'general[column]', that.params['node'], function(classObject){ 1337 that.components['column'] = classObject; 1338 }); 1339 cm.find('Com.Select', 'column', that.params['node'], function(classObject){ 1340 that.components['column'] = classObject; 1341 }); 1342 cm.find('Com.Select', 'general[view]', that.params['node'], function(classObject){ 1343 that.components['view'] = classObject; 1344 }); 1345 cm.find('Com.Select', 'view', that.params['node'], function(classObject){ 1346 that.components['view'] = classObject; 1347 }); 1348 that.processPreviesSelects(); 1349 return that; 1350 }; 1351 1352 classProto.processPreviesSelects = function(){ 1353 var that = this; 1354 var types = ['top', 'right', 'bottom', 'left', 'simple', 'grid']; 1355 var paths = {}; 1356 var preview = cm.Node('dd'); 1357 1358 var processStyleSelect = function(){ 1359 var node = that.components['style'].getNodes('container'); 1360 1361 cm.forEach(types, function(item, index) { 1362 var attr = 'data-'+ item; 1363 if(node.hasAttribute(attr)) { 1364 paths[item] = node.getAttribute(attr); 1365 } 1366 }); 1367 1368 if(Object.keys(paths).length != types.length) { 1369 return false; 1370 } 1371 $('#add_preview_after',$(node).closest('form')).after(cm.Node('dl', cm.Node('dt', 'Preview:'), preview)); 1372 that.components['style'].addEvent('onChange', function(self, value) { 1373 if (cm.isEmpty(value)) { 1374 var test = $(cm.getByAttr('name','style').item(0)).val(); 1375 if (test) value = test; 1376 1377 test = $(cm.getByAttr('name','general[style]').item(0)).val(); 1378 if (test) value = test; 1379 } 1380 1381 $(preview).empty(); 1382 preview.appendChild(cm.Node('img', { 1383 'src':paths[value] 1384 })); 1385 }); 1386 that.components['view'].triggerEvent('onChange'); 1387 }; 1388 1389 var processColumnSelect = function(){ 1390 var node = that.components['column'].getNodes('container'); 1391 that.components['column'].addEvent('onChange', function(self, value) { 1392 if (cm.isEmpty(value)){ 1393 var test = $(cm.getByAttr('name','column').item(0)).val(); 1394 if (test) value = test; 1395 1396 test = $(cm.getByAttr('name','general[column]').item(0)).val(); 1397 if (test) value = test; 1398 } 1399 $(preview).empty(); 1400 var count = parseInt(value); 1401 var list = cm.Node('ul'); 1402 for(var i=0; i<(count * 2); i++) { 1403 var item = cm.Node('li', 1404 cm.Node('div', {'class':'pt__image'}, 1405 cm.Node('div', {'class':'inner'}, 1406 cm.Node('img', { 1407 'class' : 'descr', 1408 'style' : 'width:' +(count == 1?'50%':'100%'), 1409 'src' : paths['grid'] 1410 }) 1411 ) 1412 )); 1413 1414 list.appendChild(item); 1415 } 1416 1417 preview.appendChild(cm.Node('div', {'class':'pt__grid col
1417-'+ count +' bottom'}, list)); 1418 }); 1419 }; 1420 1421 var processViewSelect = function(){ 1422 var node = that.components['view'].getNodes('container'); 1423 var column = $('#image-column').parents('dl:first'); 1424 var rows = $('#image-rows').parents('dl:first'); 1425 var paginator = $('#image-paginator').parents('dl:first'); 1426 var style = $('#image-style').parents('dl:first'); 1427 var caption = $('#image-caption').parents('dl:first'); 1428 var dimensionsaspect = $('#dimensionsaspect').parents('dl:first'); 1429 var imagespadding = $('#imagespadding').parents('dl:first'); 1430 1431 that.components['view'].addEvent('onChange', function(self, value) { 1432 if (cm.isEmpty(value)){ 1433 var test = $($(cm.getByAttr('name','view').item(0))).val(); 1434 if (test) value = test; 1435 1436 test = $($(cm.getByAttr('name','general[view]').item(0))).val(); 1437 if (test) value = test; 1438 } 1439 1440 column.hide(); 1441 rows.hide(); 1442 paginator.hide(); 1443 style.hide(); 1444 caption.hide(); 1445 dimensionsaspect.hide(); 1446 imagespadding.hide(); 1447 1448 $(preview).empty(); 1449 switch(value) { 1450 case 'slider': 1451 style.show(); 1452 dimensionsaspect.show(); 1453 imagespadding.hide(); 1454 that.components['style'].triggerEvent('onChange'); 1455 break; 1456 case 'grid': 1457 column.show(); 1458 rows.show(); 1459 paginator.show(); 1460 caption.show(); 1461 imagespadding.show(); 1462 dimensionsaspect.hide(); 1463 that.components['column'].triggerEvent('onChange'); 1464 break; 1465 } 1466 }); 1467 1468 setTimeout(function() { 1469 that.components['view'].triggerEvent('onChange'); 1470 }, 1000); 1471 }; 1472 1473 processStyleSelect(); 1474 processColumnSelect(); 1475 processViewSelect(); 1476 }; 1477}); 1478 1479 1480 1481(function () { 1482 1483 Collector.add('module_anchor', function(node) { 1484 new Module.Anchor({'node':node}); 1485 }, null, 800); 1486 1487})(); 1488 1489 1490!(function () { 1491 cm.onReady(function () { 1492 new cm.Finder('Com.Tabset', 'admin-notification', null, function (cl) { 1493 cl.addEvent('onTabShow', function (that, data) { 1494 data['callback'] && cm.ajax({'method': 'GET', 'url': data['callback'], 'onSuccess': function (response, load) { 1495 delete data['callback']; 1496 }}); 1497 }); 1498 }); 1499 }); 1500 Collector.add('messages', function (node) { 1501 var url = node.getAttribute('data-url'); 1502 if (url) { 1503 Request.send(url, {}, 'get', {'node': node}, {'overlay': false}); 1504 } 1505 }); 1506 Request.add('messages', function (details, context) { 1507 var items = [], mark = false; 1508 cm.forEach(details['data']['category'], function (el) { 1509 items.push('<li><a href="' + el['link'] + '">' + (el['mark'] ? '<span class="mark success"></span>' : '') + el['label'] + '</a></li>'); 1510 if (details['data']['mark']) { 1511 mark = true; 1512 } 1513 }); 1514 var nodes = cm.getNodes(context['node']); 1515 cm.clearNode(nodes['note']['dropdown']); 1516 cm.appendNodes(cm.strToHTML(items.join(" ")), nodes['note']['dropdown']); 1517 cm.clearNode(nodes['note']['icon']); 1518 if (mark) { 1519 cm.appendNodes(cm.strToHTML('<span class="mark"></span>'), nodes['note']['icon']); 1520 } 1521 }); 1522})(); 1523 1524 1525 1526!function () { 1527 Request.add('crud-grid-rebuild', function (details, context) { 1528 if (context && context['dialog']) { 1529 context['dialog'].close(); 1530 } 1531 var name = context['node'].getAttribute('data-gridlist'); 1532 cm.find('Com.Gridlist', name, null, function (classObject) { 1533 classObject.rebuild(); 1534 }); 1535 }); 1536 1537 Collector.add('App.Crud.BulkAction', function (node) { 1538 cm.addEvent(node, 'click', function (e) { 1539 if(cm.hasClass(node, 'button-disabled')){ 1540 return; 1541 } 1542 var name = node.getAttribute('data-gridlist'); 1543 cm.find('Com.Gridlist', name, null, function (classObject) { 1544 Request.send(node.getAttribute('href'), {'id': classObject.getCheckedIndexes()}, 'get', {'node': node}); 1545 }); 1546 cm.preventDefault(e); 1547 }, true, true); 1548 }); 1549 Collector.add('App.Crud.Search', function (node) { 1550 var form = node.getElementsByTagName('form')[0] || node; 1551 if(form){ 1552 var name = node.getAttribute('data-gridlist'); 1553 cm.addEvent(form, 'submit', function (e) { 1554 cm.find('Com.Gridlist', name, null, function (classObject) {
1555 classObject.setAction({'params': cm.getFDO(form)}); 1556 }); 1557 cm.preventDefault(e); 1558 }); 1559 cm.addEvent(form, 'reset', function (e) { 1560 cm.find('Com.Gridlist', name, null, function (classObject) { 1561 classObject.setAction({'params': {}}, 'update'); 1562 }); 1563 }); 1564 } 1565 }); 1566 Collector.add('App.Crud.Grid', function (node) { 1567 var options = { 1568 'node': node, 1569 'events': { 1570 'onRenderEnd': function (that, page) { 1571 Collector.construct(page['container']); 1572 1573 } 1574 }, 1575 'Com.Toolbar': { 1576 'events': { 1577 'onProcessEnd': function (component) { 1578 Collector.construct(component['nodes']['container']); 1579 } 1580 } 1581 } 1582 }; 1583 1584 var params = node.getAttribute('data-config'); 1585 params = cm.parseJSON(params); 1586 if (params) { 1587 options = cm.merge(options, params); 1588 } 1589 new Com.Gridlist(options); 1590 }); 1591}(); 1592 1593 1594 1595 1596 1597 1598 1599(function($) { 1600 1601 var Language = function() { 1602 var that = this; 1603 1604 var internalSaveClick = true; 1605 1606 var defaultLanguage = that.defaultLanguage = "en_US"; 1607 var current = that.current = 'en_US'; 1608 1609 var currentForm = false, 1610 oldFormData = that.oldFormData = false, 1611 newFormData = that.newFormData = false; 1612 1613 var mainFormDialogId = 'activeElement'; 1614 1615 var Dialogs = that.Dialogs = {}; 1616 1617 var log = that.log = function(string) { 1618 1619 }; 1620 1621 var setCurrent = that.setCurrent = function(language) { 1622 if (!!language) { 1623 that.current = language; 1624 } 1625 }; 1626 1627 var externalSave = that.externalSave = function( ) { 1628 internalSaveClick = false; 1629 sendData(); 1630 1631 }; 1632 1633 var internalSave = function(data) { 1634 internalSaveClick = true; 1635 //change(); 1636 sendData(); 1637 }; 1638 1639 var change = that.change = function( ) { 1640 1641 1642 1643 newFormData = getForm(currentForm); 1644 var langSelect = Com.Elements.Selects['langlocal']; 1645 delete oldFormData['langlocal']; 1646 delete newFormData['langlocal']; 1647 1648 1649 var changes = checkFormChanges(oldFormData, newFormData); 1650 var currentId = checkFormId(currentForm); 1651 if (!changes && currentId) { 1652 1653 var tpl = ''; 1654 if (!internalSaveClick) { 1655 tpl = templates.errorDefault('Please make some changes, and then save!'); 1656 } else { 1657 tpl = templates.errorDefault(); 1658 } 1659 Dialogs['errorDefault'] = makeDialog(tpl); 1660 langSelect.removeEvent('onChange', that.change); 1661 langSelect.set(defaultLanguage); 1662 langSelect.addEvent('onChange', that.change); 1663 /*} else { 1664 1665 }*/ 1666 1667 1668 } else if (changes && currentId) { 1669 if (internalSaveClick) { 1670 Dialogs['changes'] = makeDialog(templates.changes); 1671 1672 var onClose = function() { 1673 if (Dialogs['errorDefault']) { 1674 Dialogs['errorDefault'].open(); 1675 } else { 1676 Dialogs['errorDefault'] = makeDialog(templates.errorDefault()); 1677 } 1678 langSelect.removeEvent('onChange', that.change); 1679 langSelect.set(defaultLanguage); 1680 langSelect.addEvent('onChange', that.change); 1681 1682 }; 1683 cm.addEvent( 1684 Dialogs['changes'].actionNodes['save'], 1685 'click', 1686 internalSave 1687 ); 1688 $(Dialogs['changes'].actionNodes['discart']).click(onClose); 1689 $(Dialogs['changes'].getNodes().close).click(onClose); 1690 1691 } else { 1692 sendData(); 1693 } 1694 1695 1696 1697 1698 } else if (changes && !currentId) { 1699 Dialogs['changes'] = makeDialog(templates.changes); 1700 cm.addEvent( 1701 Dialogs['changes'].actionNodes['save'], 1702 'click', 1703 internalSave 1704 ); 1705 cm.addEvent( 1706 Dialogs['changes'].actionNodes['discart'], 1707 'click', 1708 function() { 1709 /* request( 1710 "GET", 1711 getFormAction() + '?' + cm.obj2URI({'langlocal' : getCurrent()}), 1712 '', 1713 formRequestHandler );*/ 1714 formRequest(getFormAction() + '?' + cm.obj2URI({'langlocal': getCurrent()})); 1715 } 1716 ); 1717 cm.addEvent( 1718 Dialogs['changes'].getNodes().close, 1719 'click', 1720 function() { 1721 formRequest(getFormAction() + '?' + cm.obj2URI({'langlocal': getCurrent()})); 1722 } 1723 ); 1724 1725 } else { 1726 formRequest(getFormAction() + '?' + cm.obj2URI({'langlocal': getCurrent()})); 1727 } 1728 }; 1729 1730 1731 var formRequest = that.formRequest = function(url) { 1732 request("GET", url, '', formRequestHandler); 1733 }; 1734 1735 var sendData = function() { 1736 if (!!Dialogs['changes']) { 1737 Dialogs['changes'].close(); 1738 } 1739 1740 var currentAction = $(currentForm).attr('action'); 1741 if (!internalSaveClick) { 1742 newFormData = getForm(currentForm); 1743 newFormData['langlocal'] = getCurrent(); 1744 } else { 1745 newFormData['langlocal'] = that.current; 1746 } 1747 1748 request("POST", currentAction, newFormData, onSaveHandler); 1749 1750 }; 1751 1752 1753 1754 var load = that.load = function() { 1755 var langSelect = Com.Elements.Selects['langlocal']; 1756 1757 if (!!langSelect) { 1758 langSelect.addEvent('onChange', that.change); 1759 } 1760 this.prefetch(); 1761 }; 1762 1763 var prefetch = that.prefetch = function() { 1764 currentForm = cm.getParentByTagName('form', cm.getEl('langlocal')); 1765 oldFormData = getForm(currentForm); 1766 }; 1767 1768 /** 1769 * Get current language from language select 1770 */ 1771 var getCurrent = that.getCurrent = function() { 1772 var langSelect = Com.Elements.Selects['langlocal']; 1773 1774 if (!!langSelect) { 1775 return langSelect.get(); 1776 } else if (!!cuttent) { 1777 return current; 1778 } 1779 return defaultLanguage; 1780 }; 1781 1782 var getForm = function(form) { 1783 if (form) { 1784 var result = {};
1785 var formData = decodeURI($(form).formSerialize().replace(/\+/g, " ")).split('&'); 1786 for (var i = 0; i < formData.length; i++) { 1787 var el = ''; 1788 var element = formData[i].split('='); 1789 if ('content' == element[0]) { 1790 el = unescape(cm.decode(element[1])); 1791 } else { 1792 el = unescape(element[1]); 1793 } 1794 result[element[0]] = el/*.replace(/\+/g, " ")*/; //decodeURIComponent( element[1] ); 1795 } 1796 return result; 1797 } 1798 return false; 1799 }; 1800 1801 1802 var checkFormChanges = function(formOld, formNew) { 1803 if ('object' == typeof formOld && 'object' == typeof formNew) { 1804 that.log(formOld); 1805 that.log(formNew); 1806 for (var element in formOld) { 1807 var elemOld = formOld[element].toString().replace(/[\n\t\r]/g, ""); 1808 var elemNew = formNew[element].toString().replace(/[\n\t\r]/g, ""); 1809 if (elemOld != elemNew) { 1810 return true; 1811 } else { 1812 1813 } 1814 } 1815 return false; 1816 } else { 1817 return false; 1818 } 1819 }; 1820 1821 var checkFormId = function(form) { 1822 var idValue = Number($(form).find('input[name=id]').val()); 1823 if (0 == idValue) { 1824 return true; 1825 } 1826 return false; 1827 }; 1828 1829 1830 var getFormAction = function(form) { 1831 return $(currentForm).attr('action'); 1832 }; 1833 1834 1835 var request = function(type, actionUrl, data, successHandler) { 1836 var overlay = new Com.Overlay(); 1837 $.ajax({type: type, 1838 url: actionUrl, 1839 data: data, 1840 dataType: 'json', 1841 success: function(responce) { 1842 overlay.close(); 1843 successHandler(responce); 1844 } 1845 }); 1846 }; 1847 1848 var makeDialog = function(objData) { 1849 var node = $(objData.content); 1850 var dialog = new Com.Dialog(cm.merge({ 1851 'name': false, 1852 'autoOpen': false, 1853 'events' : { 1854 'onOpen': function() { 1855 node.find('[data-element]').trigger('construct', dialog); 1856 node.removeAttr('title'); 1857 }, 1858 'onClose': function() { 1859 node.find('[data-element]').trigger('destruct', dialog); 1860 } 1861 } 1862 }, objData)); 1863 1864 dialog['actionNodes'] = objData.nodes; 1865 dialog.open(); 1866 1867 return dialog; 1868 }; 1869 1870 var onSaveHandler = function(responce) { 1871 if (responce.result && responce.details) { 1872 if (responce.details.url) { 1873 1874 if (internalSaveClick) { 1875 formRequest(responce.details.url + '?' + cm.obj2URI({'langlocal': getCurrent()})); 1876 } else { 1877 reload(); 1878 } 1879 1880 //formLangRequest(resp.details.url); 1881 } else if (responce.details.form) { 1882 var form = $(responce.details.form); 1883 drawForm(form); 1884 /*if( 0 != form.find('.error').length ){ 1885 var langSelect = Com.Elements.Selects['langlocal']; 1886 langSelect.removeEvent('onChange', that.change); 1887 langSelect.set(that.current); 1888 langSelect.addEvent('onChange', that.change); 1889 }*/ 1890 1891 /* langSelect.removeEvent('onChange', that.change); 1892 langSelect.set(that.current); 1893 langSelect.addEvent('onChange', that.change);*/ 1894 1895 } else { 1896 /*request( 1897 "GET", 1898 getFormAction() + '?' + cm.obj2URI({'langlocal' : getCurrent()}), 1899 '', 1900 formRequestHandler );*/ 1901 if (internalSaveClick) { 1902 formRequest(getFormAction() + '?' + cm.obj2URI({'langlocal': getCurrent()})); 1903 } else { 1904 reload(); 1905 } 1906 } 1907 1908 1909 1910 1911 } 1912 }; 1913 1914 var reload = that.reload = function() { 1915 new Com.Overlay(); 1916 window.location.reload(); 1917 1918 }; 1919 1920 1921 var formRequestHandler = function(responce) { 1922 drawForm(responce.details.form); 1923 }; 1924 1925 var drawForm = function(currentForm) { 1926 that.log('drawForm'); 1927 currentForm = $(currentForm); 1928 var form = null; 1929 var currentDialog = cm.find('Com.Dialog', mainFormDialogId, null, function (classObject) {
1930 classObject.set(title, form[0]); 1931 var nodes = classObject.getNodes(); 1932 $(nodes['inner']).find('[data-element]').trigger('construct', classObject); 1933 }); 1934 1935 if (-1 == currentForm.get(0).tagName.toLowerCase().indexOf('form')) { 1936 form = currentForm.find('form'); 1937 } else { 1938 form = currentForm; 1939 } 1940 var title = currentForm.clone().attr('title'); 1941 1942 if (!currentDialog || currentDialog.length == 0) { 1943 that.log('No dialog!'); 1944 currentDialog = makeDialog( 1945 { 1946 'name': mainFormDialogId, 1947 'autoOpen': false, 1948 'content': currentForm.get(0), 1949 'title': currentForm.clone().attr('title'), 1950 'onOpen': function() { 1951 currentForm.find('[data-element]').trigger('construct', dialog); 1952 currentForm.removeAttr('title'); 1953 }, 1954 'onClose': function() { 1955 currentForm.find('[data-element]').trigger('destruct', dialog); 1956 } 1957 } 1958 ); 1959 /* var cf = form.get(0); 1960 that.log(cf); 1961 //form.find('[data-element]').trigger('construct', form); 1962 1963 $('.content-inner form').parent().empty().html(cf); 1964 $(cf).find('[data-element]').trigger('construct', form);*/ 1965 } 1966 }; 1967 1968 var clearOfErrors = function(form) { 1969 1970 }; 1971 1972 var templates = { 1973 'errorDefault': function(message) { 1974 var message = (!!message) ? message : "Please enter content for English language"; 1975 var node = { 1976 'title': 'Warning!', 1977 'nodes': { 1978 'message': cm.Node('div', {'class': 'warning-message', 'innerHTML': message}),
1979 'closebtn': cm.Node('input', {'data-element': 'dialog-close', 'class': 'button', 'type': 'button', 'value': 'Close', 'name': 'Close'}) 1980 } 1981 1982 }; 1983 1984 var content = cm.Node('div', {'class': 'form'}, 1985 //cm.Node('div', {'innerHTML' : message }), 1986 node.nodes.message, 1987 cm.Node('hr'), 1988 cm.Node('div', {'class': 'btn-wrap'}, 1989 node.nodes.closebtn 1990 //cm.Node('input', {'data-element' : 'dialog-close', 'class': 'button', 'type' : 'button', 'value': 'Close', 'name': 'Close'}) 1991 ) 1992 ); 1993 node['content'] = content; 1994 1995 return node; 1996 }, 1997 'changes': (function() { 1998 var node = { 1999 //'id' : confirmDialogId, 2000 'title': 'Save modified data', 2001 'nodes': { 2002 'save': cm.Node('input', {'class': 'button', 'type': 'submit', 'value': 'Save', 'name': 'save'}), 2003 'discart': cm.Node('input', {'data-element': 'dialog-close', 'class': 'button', 'type': 'button', 'value': 'Cancel', 'name': 'Cancel'}) 2004 } 2005 }; 2006 var content = cm.Node('div', {'class': 'form'}, 2007 cm.Node('div', {'innerHTML': 'Content for current language was modified. Do you want to save changes?'}), 2008 cm.Node('hr'), 2009 cm.Node('div', {'class': 'btn-wrap'}, 2010 node.nodes.save, node.nodes.discart 2011 ) 2012 ); 2013 node['content'] = content; 2014 return node; 2015 })() 2016 }; 2017 2018 2019 2020 prefetch(); 2021 2022 //####### End Language 2023 }; 2024 2025 var lang = {}; 2026 2027 Collector.add('select', function(node) { 2028 if (node.id == 'langlocal') { 2029 var tabset = $('#langlocal').parents('.tabset'); 2030 if (0 < tabset.length) { 2031 var langBlock = $('#langlocal').parents('dl'); 2032 var langContainer = cm.Node('div', { 2033 'class': 'form form-language-top' 2034 }); 2035 $(tabset[0]).before(langContainer); 2036 $(langContainer).append(langBlock); 2037 } 2038 2039 setTimeout(function() { 2040 var langSelect = Com.Elements.Selects['langlocal']; 2041 if (langSelect) { 2042 lang = new Language; 2043 lang.load(); 2044 $($('#langlocal').parents('.window')[0]).find('.close').click(function() { 2045 new Com.Overlay(); 2046 window.location.reload(); 2047 2048 }); 2049 $($('#langlocal').parents('.window')[0]).find('[data-element="dialog-close"]').click(function() { 2050 new Com.Overlay(); 2051 window.location.reload(); 2052 }); 2053 $($('#langlocal').parents('.window')[0]).find('[name="save"]').die("click"); 2054 $($('#langlocal').parents('.window')[0]).find('[name="save"]').live("click", function(e) { 2055 e.preventDefault(); 2056 var href = $($('#langlocal').parents('.window')[0]).find('.form').attr('action'); 2057 lang.externalSave(); 2058 }); 2059 } 2060 }, 1000); 2061 } 2062 }); 2063 2064 2065})(window.jQuery); 2066 2067 2068 2069!function () { 2070 Collector.add('login-box', function (node) { 2071 new App.LoginBox({ 2072 'node': node 2073 }); 2074 }); 2075 Request.add('insert-form-preview', function(details, context) { 2076 var nodes = cm.getNodes(); 2077 if(nodes['UserFormBuilder']['preview']){ 2078 nodes['UserFormBuilder']['preview'].innerHTML = details.content; 2079 Collector.construct(nodes['UserFormBuilder']['preview']); 2080 } 2081 }); 2082 2083}(); 2084 2085 2086 2087 2088!function () { 2089 Request.add('page-lock', function (details, context) { 2090 cm.find('App.Lock', null, null, function (classObject) { 2091 classObject.requestHandler(details, context); 2092 }); 2093 }); 2094 Request.add('block-editor', function (details, context) { 2095 /* 2096 cm.find('App.Block', positionId, null, function(block){ 2097 cm.find('App.Editor', 'app-editor', null, function(editor){ 2098 editor.delete(block); 2099 }) 2100 }) 2101 */ 2102 cm.find('App.Editor', 'app-editor', null, function (editor) { 2103 var block = window.activeBlock || context['block']; 2104 switch (details['action']) { 2105 case 'create': 2106 editor.create(details['content'], block); 2107 break; 2108 case 'redraw':
2109 if (!details['content']) { 2110 editor.updateRequest(block); 2111 } else { 2112 editor.replace(details['content'], block); 2113 } 2114 break; 2115 case 'copy': 2116 editor.duplicate(details['content'], block); 2117 break; 2118 case 'partial': 2119 if (context['render']) { 2120 editor.replace(details['content'], block); 2121 } 2122 break; 2123 case 'undo': 2124 //editor.replace(details['content'], block); 2125 //editor.updateRequest(block); 2126 break; 2127 case 'update': 2128 editor.replace(details['content'], block); 2129 break; 2130 case 'delete': 2131 editor.delete(block); 2132 break; 2133 case 'error': 2134 editor.delete(block); 2135 console && console.log(details['content']); 2136 break; 2137 default: 2138 } 2139 }); 2140 context && context['dialog'] && context['dialog'].close(); 2141 }); 2142 2143 Collector.add('app-template', function (node) { 2144 var options = {'node': node}; 2145 var params = node.getAttribute('data-config'); 2146 if (params) { 2147 options = cm.merge(options, JSON.parse(params)); 2148 } 2149 window.Template = new App.Template(options); 2150 }, null, 990); 2151 2152 2153 Collector.add('app-topmenu', function (node) { 2154 window.TopMenu = new App.TopMenu({ 2155 'node': node 2156 }); 2157 }, null, 900); 2158 2159 Collector.add('app-sidebar', function (node) { 2160 var options = { 2161 'node': node, 2162 'events': { 2163 'onTabShow': function (that, item) { 2164 window.Collector.construct(item['tab']['container']); 2165 }, 2166 'onExpand': function (that, data) { 2167 cm.find('App.Lock', null, null, function (classObject) { 2168 classObject.startRequest(); 2169 }); 2170 }, 2171 'onCollapse': function (that, data) { 2172 cm.find('App.Lock', null, null, function (classObject) { 2173 classObject.stopRequest(); 2174 }); 2175 } 2176 } 2177 }; 2178 var params = node.getAttribute('data-config'); 2179 if (params) { 2180 options = cm.merge(options, JSON.parse(params)); 2181 } 2182 new App.Lock(cm.merge({'node': node}, options['lock'])); 2183 window.Sidebar = new App.Sidebar(options); 2184 }, null, 910); 2185 2186 Collector.add('app-zone', function (node) { 2187 new App.Zone({ 2188 'node': node 2189 }); 2190 }, null, 920); 2191 2192 Collector.add('app-block', function (node) { 2193 new App.Block({'node': node}); 2194 //set-active-block 2195 cm.addEvent(node, 'click', function (e) { 2196 cm.customEvent.trigger(node, 'set-active-block', {'direction': 'parent'}); 2197 }, true); 2198 cm.customEvent.add(node, 'set-active-block', function (params) { 2199 params.stopPropagation(); 2200 var stop = false; 2201 cm.find('App.Block', null, params['target'], function (classObject) { 2202 if(!stop){ 2203 window.activeBlock = classObject; 2204 stop = true; 2205 } 2206 }); 2207 }); 2208 }, null, 930); 2209 2210 Collector.add('app-dummy-block', function (node) { 2211 new App.DummyBlock({ 2212 'node': node 2213 }); 2214 }, null, 940); 2215 2216 Collector.add('block-editor', function (node) { 2217 var options = {'node': node}; 2218 var params = node.getAttribute('data-params'); 2219 if (params) { 2220 options = cm.merge(options, JSON.parse(params)); 2221 } 2222 window.Editor = new App.Editor({ 2223 'node': node, 2224 'events': { 2225 'createRequest': function (editor, block) { 2226 window.activeBlock = block; 2227 var lowerId = (lowerId = block.getLower()) ? lowerId.params['positionId'] : null; 2228 var upperId = (upperId = block.getUpper()) ? upperId.params['positionId'] : null; 2229 var url = options[block.params['type']]['url']['create']; 2230 var params = { 2231 'layerId': block.zone.params['layerId'], 2232 'upperId': upperId, 2233 'lowerId': lowerId, 2234 'keyword': block.params['keyword'], 2235 'parentId': block.zone.params['parentId'], 2236 'parentPositionId': block.zone.params['positionId'], 2237 'type': block.params['type'], 2238 'zone': block.zone.params['zone'] 2239 }; 2240 if( block.params['params']){ 2241 params['params'] = block.params['params']; 2242 } 2243 Request.send(url, params, 'post', {'block': block, 'editor': editor}, {'overlay': false}); 2244 }, 2245 'duplicateRequest': function (editor, block) { 2246 window.activeBlock = block; 2247 var url = options[block.params['type']]['url']['copy'].replace(/%id%|%25id%25/gi, block.params['positionId']); 2248 Request.send(url, {}, 'get', {'block': block, 'editor': editor}, {'overlay': true}); 2249 }, 2250 'replaceRequest': function (editor, block) { 2251 window.activeBlock = block; 2252 var url = options[block.params['type']]['url']['update'].replace(/%id%|%25id%25/gi, block.params['positionId']); 2253 Request.send(url, {}, 'get', {'block': block, 'editor': editor}, {'overlay': true}); 2254 }, 2255 'updateRequest': function (editor, block) { 2256 window.activeBlock = block; 2257 var url = options[block.params['type']]['url']['render'].replace(/%id%|%25id%25/gi, block.params['positionId']); 2258 Request.send(url, {}, 'get', {'block': block, 'editor': editor}, {'overlay': false}); 2259 }, 2260 'deleteRequest': function (editor, block) { 2261 window.activeBlock = block; 2262 var url = options[block.params['type']]['url']['delete'].replace(/%id%|%25id%25/gi, block.params['positionId']); 2263 Request.send(url, {}, 'get', {'block': block, 'editor': editor}, {'overlay': false}); 2264 2265 }, 2266 'moveRequest': function (editor, block) { 2267 window.activeBlock = block; 2268 var lowerId = (lowerId = block.getLower()) ? lowerId.params['positionId'] : null; 2269 var upperId = (upperId = block.getUpper()) ? upperId.params['positionId'] : null; 2270 var url = options[block.params['type']]['url']['move'].replace(/%id%|%25id%25/gi, block.params['positionId']); 2271 var params = { 2272 'layerId': block.zone.params['layerId'], 2273 'upperId': upperId, 2274 'lowerId': lowerId, 2275 'parentId': block.zone.params['parentId'], 2276 'parentPositionId': block.zone.params['positionId'], 2277 'zone': block.zone.params['zone'] 2278 }; 2279 Request.send(url, params, 'post', {'block': block, 'editor': editor}, {'overlay': false}); 2280 }, 2281 'onProcessEnd': function (editor, node) { 2282 window.Collector.construct(node); 2283 } 2284 } 2285 }); 2286 }, null, 1000); 2287 2288 Collector.add('block-columns', function (node) { 2289 var columns = new Com.Columns({'columns': node}); 2290 columns.addEvent('onResize', function (column, items) { 2291 var params = {'params': {'columns': {}}}; 2292 cm.forEach(items, function (item, key) { 2293 var config = JSON.parse(item.inner.getAttribute('data-config')); 2294 params['params']['columns'][config['zone']] = {"width": item.width}; 2295 }); 2296 Request.send(node.getAttribute('data-block-partial-url'), params, 'post', {}, {'overlay': false}); 2297 }); 2298 }); 2299 2300 Collector.add('block-spacer', function (node) { 2301 var element = new Com.Spacer({'node': node}); 2302 element.addEvent('onResize', function (el, param) { 2303 var params = { 2304 //'blockId': node.getAttribute('data-block-position-id'), 2305 'params': {'height': param.height + 'px'} 2306 }; 2307 Request.send(node.getAttribute('data-partial-url'), params, 'post', {}, {'overlay': false}); 2308 }); 2309 }); 2310 2311 Collector.add('block-imagebox', function (node) { 2312 new Com.ImageBox({'node': node}); 2313 }); 2314 2315 Collector.add('imagebox', function (node) { 2316 new Com.ImageBox({'node': node}); 2317 }); 2318 2319 Collector.add('template-choice', function (node) { 2320 var nodes = cm.getNodes(node)['AppBlockChoice']; 2321 cm.addEvent(nodes.create, 'click', function (e) { 2322 disableRemove = true; 2323 cm.customEvent.trigger(node, 'dialog-close'); 2324 }); 2325 cm.addEvent(nodes.existing, 'click', function (e) { 2326 disableRemove = true; 2327 cm.customEvent.trigger(node, 'dialog-close'); 2328 }); 2329 }); 2330 2331 Collector.add('template-item-list', function (node) { 2332 var render = function (grid, data) { 2333 if (data['row']['data']['name']) {
2334 var item = cm.Node('a', data['row']['data']['name']); 2335 cm.addEvent(item, 'click', function (e) { 2336 var params = {'params': {'id': data['row']['data']['id']}}; 2337 Request.send(node.getAttribute('data-url'), params, 'post'); 2338 disableRemove = true; 2339 cm.customEvent.trigger(node, 'dialog-close'); 2340 cm.preventDefault(e); 2341 }); 2342 data['nodes']['inner'].appendChild(item); 2343 } 2344 }; 2345 2346 var options = { 2347 'pagination': true, 2348 'perPage': 10, 2349 'container': node, 2350 'sortBy': 'name', 2351 'orderBy': 'ASC', 2352 'cols': [{ 2353 'key': 'name', 2354 'type': 'empty', 2355 'width': 'auto', 2356 'title': 'Name', 2357 'onRender': render 2358 }] 2359 }; 2360 var params = node.getAttribute('data-params'); 2361 params = cm.parseJSON(params); 2362 if (params) { 2363 options = cm.merge(options, params); 2364 } 2365 new Com.Gridlist(options); 2366 }); 2367 2368 Collector.add('select', function (node) { 2369 if (node.name === 'block[language_filter]') { 2370 var select = Com.GetSelect('language_filter'); 2371 if (select) { 2372 var hide = function (select, value) { 2373 var languages = cm.getEl('language'); 2374 var el = languages.parentNode.parentNode; 2375 el.style.display = (value === 'specific' ? '' : 'none'); 2376 }; 2377 select.addEvent('onChange', hide); 2378 hide(select, select.get()); 2379 } 2380 } 2381 if (node.name === 'block[plan_filter]') { 2382 var select = Com.GetSelect('plan_filter'); 2383 if (select) { 2384 var hide = function (select, value) { 2385 var plans = cm.getEl('plan'); 2386 var el = plans.parentNode.parentNode; 2387 el.style.display = (value === 'specific' ? '' : 'none'); 2388 }; 2389 select.addEvent('onChange', hide); 2390 hide(select, select.get()); 2391 } 2392 } 2393 }); 2394 2395 Collector.add('delete-block-dialog', function (node) { 2396 var nodes = cm.getNodes(node); 2397 cm.forEach(nodes.buttons, function (item, key) { 2398 cm.addEvent(item, 'click', function (e) { 2399 nodes.scenario.value = this.name; 2400 }); 2401 }); 2402 }); 2403 2404 AppEvent.add(document, 'dialog-close', function (details, context) { 2405 switch (details['name']) { 2406 case 'block-choice': 2407 case 'block-item-list': 2408 case 'block-form': 2409 case 'block-editor-form': 2410 if (!disableRemove) { 2411 if (window.activeBlock.isDummy) { 2412 cm.find('App.Editor', 'app-editor', null, function (editor) { 2413 editor.delete(window.activeBlock); 2414 }); 2415 } 2416 } 2417 break; 2418 } 2419 }); 2420 2421 var disableRemove = false; 2422 AppEvent.add(document, 'dialog-open', function (details, context) { 2423 switch (details['name']) { 2424 case 'block-choice': 2425 case 'block-item-list': 2426 case 'block-form': 2427 disableRemove = false; 2428 break; 2429 } 2430 }); 2431 2432 Collector.add('template_code_highlight', function (node) { 2433 new Com.CodeHighlight({'node': node}); 2434 }); 2435 2436 Collector.add('module__workingarea', function (node) { 2437 new Module.WorkingArea({'node': node}); 2438 }); 2439 2440 Collector.add('button-unveil', function (node) { 2441 var params = node.getAttribute('data-config'); 2442 var hendler = function (classObject) { 2443 classObject.addEvent('onChange', function(element, value) { 2444 var nodes = cm.getNodes(); 2445 if ('url' == value) { 2446 cm.addClass(nodes['AppForm']['file'], 'display-none'); 2447 cm.removeClass(nodes['AppForm']['url'], 'dis
2447play-none'); 2448 } 2449 if ('file' == value) { 2450 cm.addClass(nodes['AppForm']['url'], 'display-none'); 2451 cm.removeClass(nodes['AppForm']['file'], 'display-none'); 2452 } 2453 }); 2454 classObject.triggerEvent('onChange', classObject.get()); 2455 }; 2456 new cm.Finder('Com.Select', params['name'], node, hendler); 2457 }); 2458}(); 2459 2460 2461 2462cm.define('App.Lock', { 2463 'extend': 'Com.AbstractController', 2464 'params': { 2465 'name': 'app-lock', 2466 'renderStructure': false, 2467 'embedStructureOnRender': false, 2468 'interval': 5000, 2469 'overlay': true, 2470 'enabled': false, 2471 'getDataConfig' : false, 2472 'urls': { 2473 'persistent': '', 2474 'claim': '', 2475 'lock': '', 2476 'unlock': '', 2477 'check': '' 2478 } 2479 } 2480}, 2481function (params) { 2482 var that = this; 2483 that.persistentTimer = null; 2484 that.checkTimer = null; 2485 that.activeRequest = null; 2486 // Call parent class construct 2487 Com.AbstractController.apply(that, arguments); 2488}); 2489 2490cm.getConstructor('App.Lock', function (classConstructor, className, classProto) { 2491 var _inherit = classProto._inherit; 2492 2493 classProto.clearTimers = function () { 2494 var that = this; 2495 that.persistentTimer && clearTimeout(that.persistentTimer); 2496 that.checkTimer && clearTimeout(that.checkTimer); 2497 that.activeRequest && that.activeRequest.abort(); 2498 that.activeRequest = null; 2499 }; 2500 classProto.stopRequest = function () { 2501 var that = this; 2502 if (!that.params['enabled']) { 2503 return; 2504 } 2505 if (that.persistentTimer) { 2506 that.clearTimers(); 2507 that.activeRequest = window.Request.send(that.params['urls']['unlock'], {}, 'get', {}, {'overlay': false}); 2508 } 2509 }; 2510 classProto.startRequest = function () { 2511 var that = this; 2512 if (!that.params['enabled']) { 2513 return; 2514 } 2515 that.clearTimers(); 2516 that.activeRequest = window.Request.send(that.params['urls']['lock'], {}, 'get', {}, {'overlay': that.params['overlay']}); 2517 }; 2518 classProto.startCheckRequest = function () { 2519 var that = this; 2520 if (!that.params['enabled']) { 2521 return; 2522 } 2523 that.clearTimers(); 2524 that.checkTimer = setInterval(function () { 2525 if (!that.activeRequest) { 2526 that.activeRequest = window.Request.send(that.params['urls']['check'], {}, 'get', {}, {'overlay': false}); 2527 } 2528 }, that.params['interval']); 2529 }; 2530 classProto.startPersistentRequest = function () { 2531 var that = this; 2532 if (!that.params['enabled']) { 2533 return; 2534 } 2535 that.clearTimers(); 2536 that.persistentTimer = setInterval(function () { 2537 if (!that.activeRequest) { 2538 that.activeRequest = window.Request.send(that.params['urls']['persistent'], {}, 'get', {}, {'overlay': false}); 2539 } 2540 }, that.params['interval']); 2541 }; 2542 classProto.requestHandler = function (details, context) { 2543 var that = this; 2544 if (!that.params['enabled']) { 2545 return; 2546 } 2547 that.activeRequest = null; 2548 switch (details['action']) { 2549 case 'persistent': 2550 case 'notify-free': 2551 case 'notify-locked': 2552 break; 2553 case 'dialog': 2554 that.clearTimers(); 2555 //create new or select existing dialog 2556 var content = cm.strToHTML(details['content']); 2557 var dialog = new Com.Dialog({ 2558 'content': content, 2559 'events': { 2560 'onOpen': function () { 2561 //close all editors 2562 if( typeof CKEDITOR !== "undefined" ){ 2563 cm.forEach(CKEDITOR.instances, function (instance) { 2564 instance.fire('blur'); 2565 instance.destroy(); 2566 }); 2567 } 2568 cm.customEvent.add(content, 'dialog-close', function (params) { 2569 cm.find('Com.Dialog', null, null, function (classObject) { 2570 classObject.remove(); 2571 }); 2572 }); 2573 }, 2574 'onOpenStart': function () { 2575 Collector.construct(content); 2576 }, 2577 'onClose': function () { 2578 Collector.destruct(content); 2579 cm.find('App.Sidebar', null, null, function (classObject) { 2580 classObject.collapse(false, true); 2581 }); 2582 that.startCheckRequest(); 2583 } 2584 } 2585 }); 2586 break; 2587 case 'lock': 2588 that.startPersistentRequest(); 2589 break; 2590 case 'unlock': 2591 that.startCheckRequest(); 2592 break; 2593 } 2594 }; 2595}); 2596 2597 2598 2599 2600cm.define('App.FormPageSettings', { 2601 'modules': [ 2602 'Params', 2603 'Events', 2604 'Langs', 2605 'DataConfig', 2606 'DataNodes'
2607 ], 2608 'events': [ 2609 'onRender' 2610 ], 2611 'params': { 2612 'node': cm.Node('div'), 2613 'name': '' 2614 } 2615}, 2616function (params) { 2617 var that = this; 2618 that.components = {}; 2619 var init = function () { 2620 that.setParams(params); 2621 that.convertEvents(that.params['events']); 2622 that.getDataNodes(that.params['node']); 2623 that.getDataConfig(that.params['node']); 2624 render(); 2625 that.triggerEvent('onRender'); 2626 }; 2627 2628 var render = function () { 2629 /* metaTitle */ 2630 var metaTitle = function () { 2631 var count = that.nodes['metaTitle'].getAttribute('data-maxLength') - that.nodes['metaTitle'].value.length; 2632 var hintText = that.nodes['metaTitleHint'].getAttribute('data-text'); 2633 var hint = (count < 0) ? '<span style="color:red">'+count + ' ' + hintText+'</span>' : count + ' ' + hintText; 2634 that.nodes['metaTitleHint'].innerHTML = hint; 2635 }; 2636 cm.addEvent(that.nodes['metaTitle'], 'input', metaTitle); 2637 metaTitle(); 2638 2639 /* metaKeywords */ 2640 var metaKeywords = function () { 2641 var count = that.nodes['metaKeywords'].getAttribute('data-maxLength') - that.nodes['metaKeywords'].value.length; 2642 var hintText = that.nodes['metaKeywordsHint'].getAttribute('data-text'); 2643 var hint = (count < 0) ? '<span style="color:red">'+count + ' ' + hintText+'</span>' : count + ' ' + hintText; 2644 that.nodes['metaKeywordsHint'].innerHTML = hint; 2645 }; 2646 cm.addEvent(that.nodes['metaKeywords'], 'input', metaKeywords); 2647 metaKeywords(); 2648 2649 /* metaDescr */ 2650 var metaDescr = function () { 2651 var count = that.nodes['metaDescr'].getAttribute('data-maxLength') - that.nodes['metaDescr'].value.length; 2652 var hintText = that.nodes['metaDescrHint'].getAttribute('data-text'); 2653 var hint = (count < 0) ? '<span style="color:red">'+count + ' ' + hintText+'</span>' : count + ' ' + hintText; 2654 that.nodes['metaDescrHint'].innerHTML = hint; 2655 }; 2656 cm.addEvent(that.nodes['metaDescr'], 'input', metaDescr); 2657 metaDescr(); 2658 2659 /* publishingstatus */ 2660 var publishingstatus = function (element, value) { 2661 if ('always' == value) { 2662 cm.addClass(that.nodes['startpublishing'], 'display-none'); 2663 cm.addClass(that.nodes['stoppublishing'], 'display-none'); 2664 } else { 2665 cm.removeClass(that.nodes['startpublishing'], 'display-none'); 2666 cm.removeClass(that.nodes['stoppublishing'], 'display-none'); 2667 } 2668 }; 2669 new cm.Finder('Com.Select', 'publishingstatus', that.params['node'], function (classObject) { 2670 that.components['publishingstatus'] = classObject; 2671 that.components['publishingstatus'].addEvent('onChange',publishingstatus); 2672 publishingstatus(that.components['publishingstatus'],that.components['publishingstatus'].get()); 2673 }); 2674 if(that.nodes['isfile']) { 2675 new cm.Finder('Com.Select', 'isfile', that.nodes['container'], function (classObject) { 2676 that.components['isfile'] = classObject; 2677 classObject.addEvent('onChange', function(element, value) { 2678 if ('No' == value) { 2679 cm.addClass(that.nodes['file'], 'display-none'); 2680 cm.removeClass(that.nodes['url'], 'display-none'); 2681 } 2682 if ('Yes' == value) { 2683 cm.addClass(that.nodes['url'], 'display-none'); 2684 cm.removeClass(that.nodes['file'], 'display-none'); 2685 } 2686 }); 2687 classObject.triggerEvent('onChange', classObject.get()); 2688 }); 2689 } 2690 /*isurl*/ 2691 if(that.nodes['isurl']) { 2692 var isurl = function (event) { 2693 if (this.checked || event.checked) { 2694 cm.removeClass(that.nodes['newwindow'], 'display-none'); 2695 if (that.components['isfile']) { 2696 cm.removeClass(that.nodes['isfile'], 'dis
2696play-none'); 2697 that.components['isfile'].triggerEvent('onChange', that.components['isfile'].get()); 2698 }else{ 2699 cm.removeClass(that.nodes['url'], 'display-none'); 2700 } 2701 } else { 2702 if (that.components['isfile']) { 2703 that.components['isfile'].set('No'); 2704 } 2705 cm.addClass(that.nodes['newwindow'], 'display-none'); 2706 cm.addClass(that.nodes['isfile'], 'display-none'); 2707 cm.addClass(that.nodes['file'], 'display-none'); 2708 cm.addClass(that.nodes['url'], 'display-none'); 2709 } 2710 }; 2711 cm.addEvent(that.nodes['isurl'], 'click', isurl); 2712 isurl(that.nodes['isurl'], that.nodes['isurl'].checked); 2713 } 2714 /* spoiler */ 2715 var spoiler = function () { 2716 cm.find('Com.ToggleBox', 'advanced', that.nodes['container'], function(classObject){ 2717 // Render Fields 2718 var container = cm.node('div'); 2719 cm.forEach(that.nodes['spoiler'], function(item){ 2720 cm.appendChild(item,container); 2721 }); 2722 // Embed 2723 classObject.setContent(container); 2724 }); 2725 }; 2726 spoiler(); 2727 2728 }; 2729 2730 /* ******* MAIN ******* */ 2731 init(); 2732}); 2733 2734!function () { 2735 Collector.add('form_page_settings', function (node) { 2736 new App.FormPageSettings({'node' : node}); 2737 }); 2738 2739 Collector.addEvent('onConstruct', function () { 2740 Part.Menu(); 2741 }); 2742}(); 2743 2744 2745 2746 2747function Date_toYMD(date) { 2748 var year, month, day; 2749 year = String(date.getFullYear());
2750 month = String(date.getMonth() + 1); 2751 if (month.length == 1) { 2752 month = "0" + month; 2753 } 2754 day = String(date.getDate()); 2755 if (day.length == 1) { 2756 day = "0" + day; 2757 } 2758 return year + "-" + month + "-" + day; 2759} 2760 2761 2762cm.define('App.PartBillingInvoices', { 2763 'modules': [ 2764 'Params', 2765 'Events', 2766 'Langs', 2767 'DataConfig', 2768 'DataNodes', 2769 'Stack' 2770 ], 2771 'events': [ 2772 'onRender' 2773 ], 2774 'params': { 2775 'node': cm.Node('div'), 2776 'name': '' 2777 } 2778}, 2779function (params) { 2780 var that = this; 2781 2782 that.nodes = { 2783 'container': cm.node('div'), 2784 'buttons': { 2785 'search': cm.node('div') 2786 } 2787 }; 2788 that.components = {}; 2789 2790 var init = function () { 2791 2792 that.setParams(params); 2793 that.convertEvents(that.params['events']); 2794 that.getDataNodes(that.params['node']); 2795 that.getDataConfig(that.params['node']); 2796 that.addToStack(that.params['node']); 2797 render(); 2798 that.triggerEvent('onRender'); 2799 }; 2800 2801 var render = function () { 2802 // Get Form Buttons 2803 cm.addEvent(that.nodes['buttons']['search'], 'click', searchAction); 2804 cm.addEvent(that.nodes['buttons']['reset'], 'click', resetAction); 2805 // Get Paginator 2806 new cm.Finder('Com.Pagination', null, that.nodes['container'], processPagination); 2807 }; 2808 2809 var processPagination = function (classObject) { 2810 that.components['pagination'] = classObject; 2811 }; 2812 2813 var resetAction = function (e) { 2814 cm.preventDefault(e); 2815 cm.find('Com.Datepicker', 'statements-from', that.nodes['container'], function (DatepickerObject) { 2816 if ('object' == typeof DatepickerObject && 'set' in DatepickerObject && 'function' == typeof DatepickerObject.set) { 2817 DatepickerObject.clear(); 2818 } 2819 }); 2820 cm.find('Com.Datepicker', 'statements-to', that.nodes['container'], function (DatepickerObject) { 2821 if ('object' == typeof DatepickerObject && 'set' in DatepickerObject && 'function' == typeof DatepickerObject.set) { 2822 DatepickerObject.clear(); 2823 } 2824 }); 2825 2826 2827 searchAction(e); 2828 }; 2829 2830 var searchAction = function (e) { 2831 cm.preventDefault(e); 2832 2833 var form = cm.getEl('billing-statements-form'); 2834 var data = cm.getFDO(form); 2835 var params = { 'page': '%page%' }; 2836 2837 2838 if (('statements-from' in data && data['statements-from'] != "0000-00-00") || 2839 ('statements-to' in data && data['statements-to'] != "0000-00-00")) { 2840 2841 params['statements-from'] = data['statements-from']; 2842 params['statements-to'] = data['statements-to']; 2843 } else { // Hardcoded! Remove when pagination params will be fixed. 2844 params['statements-from'] = "1970-01-01"; 2845 params['statements-to'] = Date_toYMD(new Date); 2846 } 2847 2848 that.components['pagination'].rebuild({ 2849 'ajax': { 2850 'url': '/billing/search', 2851 'type': 'json', 2852 'method': 'get', 2853 'params' : params 2854 }, 2855 }); 2856 }; 2857 init(); 2858}); 2859 2860 2861!function ($) { 2862 2863 //move to application module js 2864 Collector.add('MultipleAutocomplete', function (node) { 2865 var options = { 2866 'node': node, 2867 'name': node.getAttribute('name'), 2868 'clearOnEmpty': true, 2869 'showListOnEmpty' : true, 2870 }; 2871 if(node.children.length>0){ 2872 var data = []; 2873 cm.forEach(node.children, function (item) { 2874 data.push({'value':item.value, 'text':item.innerHTML}); 2875 }); 2876 options['value'] = data; 2877 } 2878 var params = node.getAttribute('data-config'); 2879 params = cm.parseJSON(params); 2880 if (params) { 2881 options = cm.merge(options, params); 2882 } 2883 new Com.MultipleAutocomplete(options); 2884 }); 2885 2886 Collector.add('select', function (node) { 2887 2888 if (node.name === 'billing-profile') { 2889 var billingCardId = Com.GetSelect('billing-profile'); 2890 var elementConteiner = cm.getEl('billing-profile-content'); 2891 var makeActiveCard = cm.getEl('makedefault-billing-profile'); 2892 2893 if (billingCardId) { 2894 if (cm.isNode(elementConteiner)) { 2895 billingCardId.addEvent('onSelect', function (select, active) { 2896 cm.clearNode(elementConteiner); 2897 }); 2898 } 2899 2900 if (cm.isNode(makeActiveCard)) { 2901 function _makeActive(node, currentValue) { 2902 2903 //return false;
2904 var activeValue = node.getAttribute('data-params-active'); 2905 2906 if (!!activeValue) { 2907 if (!!currentValue && Number(activeValue) != Number(currentValue)) { 2908 node.parentNode.style.visibility = 'visible'; 2909 } else { 2910 node.parentNode.style.visibility = 'hidden'; 2911 } 2912 2913 return true; 2914 } 2915 return false; 2916 } 2917 2918 billingCardId.addEvent('onSelect', function (select, active) { 2919 _makeActive(makeActiveCard, active); 2920 }); 2921 2922 _makeActive(makeActiveCard, billingCardId.get()); 2923 } 2924 2925 } 2926 } else if (node.name === 'bcountry') { 2927 var selectName = node.id; 2928 2929 var selectCountries = Com.GetSelect(selectName); 2930 if('object' == typeof selectCountries && selectCountries instanceof Com.Select){ 2931 selectCountries.addEvent('onChange', function(select, value){ 2932 var countryNode = cm.getEl('signup_country'); 2933 if(cm.isNode(countryNode)){ 2934 var url = countryNode.getAttribute('data-url'); 2935 var params = { 2936 'country' : selectCountries.get() 2937 }; 2938 Request.send(url, params, 'post', {}, {'overlay': false}); 2939 } 2940 }); 2941 } 2942 } 2943 }); 2944 2945 Collector.add('billing-profile-form', function (node) { 2946 cm.addEvent(node, 'submit', function (e) { 2947 Collector.destruct(node); 2948 var data = {}; 2949 cm.find('Com.MultipleAutocomplete', null, node, function (object) { 2950 var val = object.get(); 2951 if(val.length>0) { 2952 var name = object.params.name; 2953 data[name.substr(0, name.length-2)] = val; 2954 } 2955 }); 2956 Request.send(node.getAttribute('action'), data, 'post', {'node': node}); 2957 cm.preventDefault(e); 2958 }); 2959 }); 2960 2961 Collector.add('invoicePDF', function (node) { 2962 cm.addEvent(node, 'click', function (e) { 2963 cm.preventDefault(e); 2964 var overlay = new Com.Overlay({ 2965 autoOpen: true, 2966 lazy: true 2967 }); 2968 // Kill all previous iframes 2969 var frames = node.parentNode.getElementsByTagName('iframe'); 2970 if(!!frames && 0 < frames.length){ 2971 for(var i = 0; i < frames.length; i++){ 2972 cm.remove(frames[i]); 2973 } 2974 } 2975 // Render iframe 2976 var url = node.getAttribute('href'); 2977 var frame = cm.node('iframe', { 2978 'style':'width:0; height:0; display:none; border:0px;', 2979 'class':'iframe-ghost', 2980 'src' : url 2981 }); 2982 cm.addEvent(frame, 'load', function(e){ 2983 if (overlay) { 2984 overlay.close(); 2985 } 2986 setTimeout(function(){ 2987 cm.remove(frame); 2988 }, 350); 2989 }); 2990 cm.appendChild(frame, node.parentNode); 2991 // Kill overlay if something goes wrong 2992 setTimeout(function(){ 2993 if (overlay) { 2994 overlay.close(); 2995 } 2996 }, 5000); 2997 }); 2998 }); 2999 3000 Collector.add('makedefault-billing-profile', function (node) { 3001 3002 cm.addEvent(node, 'click', function (e) { 3003 3004 var select = Com.GetSelect('billing-profile'); 3005 var v = select.get(); 3006 if (v == 'new') { 3007 return; 3008 } 3009 $.get(node.getAttribute('data-url') + '/' + v).success(function (response) { 3010 if ('result' in response && !!response.result) { 3011 3012 if ('details' in response && 'object' == typeof response.details && 3013 'current_card' in response.details && 0 < Number(response.details.current_card)) { 3014 node.setAttribute('data-params-active', response.details.current_card); 3015 } 3016 3017 node.parentNode.style.visibility = 'hidden'; 3018 } else { 3019 node.parentNode.style.visibility = 'visible'; 3020 } 3021 3022 }); 3023 }); 3024 }); 3025 3026 Collector.add('add-billing-profile', function (node) { 3027 cm.addEvent(node, 'click', function (e) { 3028 var url = node.getAttribute('data-url'); 3029 3030 //cm.getEl('billing-profile-form').action = url; 3031 //$.get(node.getAttribute('data-url')).success(function (response) { 3032 $.ajax({ 3033 type: "GET", 3034 url: url, 3035 success: function (response) { 3036 var element = cm.getEl('billing-profile-content'); 3037 if (response.result) { 3038 var select = Com.GetSelect('billing-profile'); 3039 element.innerHTML = response.details.form; 3040 Collector.construct(element); 3041 cm.getEl('billing-profile-form').action = url; 3042 // addCallBack(); 3043 } 3044 } 3045 }); 3046 }); 3047 }); 3048 3049 Collector.add('edit-billing-profile', function (node) { 3050 cm.addEvent(node, 'click', function (e) { 3051 var select = Com.GetSelect('billing-profile'); 3052 var v = select.get(); 3053 if (v == 'new') { 3054 return; 3055 } 3056 var url = node.getAttribute('data-url') + '/' + v; 3057 //cm.getEl('billing-profile-form').action = url; 3058 3059 $.ajax({ 3060 type: "GET", 3061 url: url, 3062 success: function (response) { 3063 if ('object' == typeof response) { 3064 var element = cm.getEl('billing-profile-content'); 3065 if ('result' in response && !!response.result) { 3066 if ('details' in response && 'object' == typeof response.details) { 3067 if ('form' in response.details) { 3068 3069 var select = Com.GetSelect('billing-profile'); 3070 element.innerHTML = response.details.form; 3071 Collector.construct(element); 3072 3073 cm.getEl('billing-profile-form').action = url; 3074 3075 //addCallBack(); 3076 } 3077 } 3078 } 3079 } 3080 } 3081 }); 3082 }); 3083 }); 3084 3085 Collector.add('remove-billing-profile', function (node) { 3086 cm.addEvent(node, 'click', function (e) { 3087 var select = Com.GetSelect('billing-profile'); 3088 var v = select.get(); 3089 if (v == 'new') { 3090 return; 3091 } 3092 3093 var url = node.getAttribute('data-url') + '/' + v; 3094 3095 $.ajax({ 3096 type: "GET", 3097 url: url, 3098 success: function (response) { 3099 if ('object' != typeof response) { 3100 return false;
3101 } 3102 3103 if ('result' in response) { 3104 if (!!response.result) { 3105 window.location.reload(); 3106 } else { 3107 if ('message' in response) { 3108 var element = cm.getEl('billing-profile-content'); 3109 if (cm.isNode(element)) { 3110 element.innerHTML = response.message.toString(); 3111 } 3112 } 3113 } 3114 } 3115 } 3116 }); 3117 }); 3118 }); 3119 3120 Collector.add('form-manage-cards-hide', function (node) { 3121 cm.addEvent(node, 'click', function (e) { 3122 cm.preventDefault(e); 3123 var element = cm.getEl('billing-profile-content'); 3124 if(element && cm.isNode(element)){ 3125 cm.clearNode(element); 3126 } 3127 }); 3128 }); 3129 3130 Collector.add('manage-cards-form', function (node) { 3131 3132 cm.addEvent(node, 'click', function (e) { 3133 cm.preventDefault(e); 3134 3135 var form = cm.getEl('upgrade-profile-form'); 3136 var data = cm.getFDO(form); 3137 overlay = new Com.Overlay({autoOpen: false}); 3138 setTimeout(function () { 3139 if (overlay) { 3140 overlay.open(); 3141 } 3142 }, 100); 3143 3144 $.ajax({ 3145 type: "POST", 3146 url: form.action, 3147 data: data, 3148 success: function (data) { 3149 if (overlay) { 3150 overlay.close(); 3151 } 3152 var billingCardId = Com.GetSelect('billing-profile'); 3153 3154 var element = cm.getEl('billing-profile-content'); 3155 var elementMessage = cm.getEl('billing-profile-message'); 3156 3157 if ('object' != typeof data) { 3158 element.innerHTML = ''; 3159 elementMessage.innerHTML = ''; 3160 3161 return false; 3162 } 3163 var dataContainer = data; 3164 var cleanForm = true; 3165 3166 if ('details' in data && 'object' == typeof data.details) { 3167 dataContainer = data.details; 3168 cleanForm = false; 3169 } 3170 3171 if ('message' in dataContainer) { 3172 elementMessage.innerHTML = "<br>" + dataContainer.message.toString(); 3173 } 3174 if ('cards' in dataContainer) { 3175 var billingCardId = Com.GetSelect('billing-profile'); 3176 if (billingCardId) { 3177 billingCardId.removeOptionsAll(); 3178 for (var item in dataContainer.cards) { 3179 3180 billingCardId.addOption(item, dataContainer.cards[item]); 3181 } 3182 if ('active' in dataContainer) { 3183 billingCardId.set(dataContainer.active); 3184 } 3185 } else { 3186 window.location.reload(); 3187 } 3188 } 3189 if ('form' in dataContainer) { 3190 element.innerHTML = dataContainer.form; 3191 } 3192 if ('reload' in dataContainer) { 3193 window.location.reload(); 3194 } 3195 3196 if (!!cleanForm) { 3197 element.innerHTML = ''; 3198 } 3199 3200 Collector.construct(elementMessage); 3201 Collector.construct(element); 3202 3203 } 3204 }); 3205 }); 3206 }); 3207 3208 Request.add('billing-get-state', function (details, context) { 3209 3210 var state = Com.GetSelect('signup_state'); 3211 3212 var stateDisabled = state.disabled; 3213 3214 if (cm.isEmpty(details.states)) { 3215 state.removeOptionsAll(); 3216 state.addOption('none', cm.getEl('signup_state').getAttribute('data-text')); 3217 state.set('none'); 3218 return; 3219 } 3220 state.enable(); 3221 if (state) { 3222 if (state.getOptionsAll()) { 3223 state.removeOptionsAll(); 3224 }
3225 cm.forEach(details.states, function (item, key) { 3226 state.addOption(key, item); 3227 }); 3228 if (details.data.param) { 3229 state.set(details.data.param); 3230 } else { 3231 var all = state.getOptionsAll(); 3232 if (all.length) { 3233 state.set(all[0].value); 3234 } 3235 } 3236 3237 if(!!stateDisabled){ 3238 state.disable(); 3239 } 3240 } 3241 }); 3242 3243 Collector.add('part_billing-invoices', function (node) { 3244 new App.PartBillingInvoices({'node': node}); 3245 }); 3246 3247}(window.jQuery); 3248 3249 3250 3251 3252 3253 3254 3255 3256!function($) { 3257 Collector.add('cron', function(node) { 3258 var language = config.lang; 3259 if(config.lang.search('_')>0){ 3260 language = config.lang.substr(0, config.lang.search('_')) 3261 } 3262 $(node).jqCron({ 3263 enabled_minute: true, 3264 multiple_dom: true, 3265 multiple_month: true, 3266 multiple_mins: true, 3267 multiple_dow: true, 3268 multiple_time_hours: true, 3269 multiple_time_minutes: true, 3270 default_period: 'week', 3271 default_value: '15 * * * *', 3272 no_reset_button: false, 3273 lang: language 3274 }); 3275 }); 3276}(window.jQuery); 3277 3278 3279 3280//ckeditor filebrowser config 3281if( typeof CKEDITOR !== "undefined" ){ 3282 CKEDITOR.config.filebrowserBrowseUrl = window.config.url + '/admin/file-manager/browser'; 3283} 3284if (!window.config.hasOwnProperty('googlemap')){ 3285 window.config.googlemap = { apikey: '' }; 3286} 3287 3288//elFinder default config 3289ELFINDER = { 3290 config: { 3291 url: config.url + '/admin/file-manager/connector', //#FIXME 3292 lang : window.config.lang.substr(0, window.config.lang.search('_')), 3293 baseUrl: window.config.assets + 'lib/elFinder/', 3294 themes:{ 3295 'default' : { 3296 'name': 'Material Light', 3297 'cssurls': 'theme/material/css/theme-light.min.css', 3298 'author': 'Róbert KelÄák {RobiNN}', 3299 'license': 'The MIT License (MIT)' 3300 }, 3301 'material' : { 3302 'name': 'Material', 3303 'cssurls': 'theme/material/css/theme.min.css', 3304 'author': 'Róbert KelÄák {RobiNN}', 3305 'license': 'The MIT License (MIT)' 3306 }, 3307 'material-gray' : { 3308 'name': 'Material Gray', 3309 'cssurls': 'theme/material/css/theme-gray.min.css', 3310 'author': 'Róbert KelÄák {RobiNN}', 3311 'license': 'The MIT License (MIT)' 3312 }, 3313 'el-finder' : { 3314 'name': 'elFinder', 3315 'cssurls': 'css/theme.css', 3316 'author': 'elFinder Project', 3317 'license': '3-clauses BSD' 3318 }, 3319 }, 3320 //width: 900, 3321 dotFiles: false, 3322 destroyOnClose: true, 3323 useBrowserHistory: false, 3324 commandsOptions: { 3325 getfile: { 3326 oncomplete: 'close', 3327 folders: false, 3328 multiple: false 3329 }, 3330 quicklook:{ 3331 googleMapsApiKey: window.config.googlemap.apikey || '' 3332 } 3333 } 3334 } 3335}; 3336 3337ELFINDER_EMBED = { 3338 config : { 3339 url : config.url + '/admin/file-manager/connector', //#FIXME 3340 lang : window.config.lang.substr(0, window.config.lang.search('_')), 3341 baseUrl: window.config.assets + 'lib/elFinder/', 3342 themes:{ 3343 'default' : { 3344 'name': 'Material Light', 3345 'cssurls': 'theme/material/css/theme-light.min.css', 3346 'author': 'Róbert KelÄák {RobiNN}', 3347 'license': 'The MIT License (MIT)' 3348 }, 3349 'material' : { 3350 'name': 'Material', 3351 'cssurls': 'theme/material/css/theme.min.css', 3352 'author': 'Róbert KelÄák {RobiNN}', 3353 'license': 'The MIT License (MIT)' 3354 }, 3355 'material-gray' : { 3356 'name': 'Material Gray', 3357 'cssurls': 'theme/material/css/theme-gray.min.css', 3358 'author': 'Róbert KelÄák {RobiNN}', 3359 'license': 'The MIT License (MIT)' 3360 }, 3361 'el-finder' : { 3362 'name': 'elFinder', 3363 'cssurls': 'css/theme.css', 3364 'author': 'elFinder Project', 3365 'license': '3-clauses BSD' 3366 }, 3367 }, 3368 dotFiles : false, 3369 useBrowserHistory : false, 3370 resizable : false, 3371 commandsOptions : { 3372 getfile : { 3373 folders: false, 3374 multiple: false 3375 }, 3376 quicklook:{ 3377 googleMapsApiKey: window.config.googlemap.apikey || '' 3378 } 3379 } 3380 } 3381}; 3382 3383cm.setParams('App.elFinderFileManager', { 3384 'config' : ELFINDER_EMBED.config 3385}); 3386 3387cm.setParams('Com.FileStats', config.quota); 3388 3389 3390 3391!function () { 3392 3393 if(!localStorage.getItem('migr13051')) { 3394 localStorage.removeItem('elfinder-lastdir'); 3395 localStorage.removeItem('/admin/file-manager/index-elfinder-lastdirelFinder'); 3396 localStorage.removeItem('/admin/file-manager/browser-elfinder-lastdirelFinder'); 3397 localStorage.setItem('migr13051', 1); 3398 } 3399 3400 /* 3401 * Request for open multiple upload form 3402 */ 3403 Collector.add('App.FileMultipleUploader', function (node) { 3404 var options = { 3405 'node' : node, 3406 'events' : { 3407 'onComplete':function(component, items){
3408 Request.send(options['url'], {'files': items, 'start': true}, 'post'); 3409 } 3410 } 3411 }; 3412 var params = node.getAttribute('data-config'); 3413 params = cm.parseJSON(params); 3414 if (params) { 3415 options = cm.merge(options, params); 3416 } 3417 new App.FileUploaderContainer(options); 3418 }); 3419 /* 3420 * Button for open file uploader 3421 */ 3422 Collector.add('App.FileUploaderContainer', function (node) { 3423 new App.FileUploaderContainer({'node':node}); 3424 }); 3425 /* 3426 * Single file upload element 3427 */ 3428 Collector.add('App.FileInput', function (node) { 3429 var options = {'node' : node}; 3430 var params = node.getAttribute('data-config'); 3431 params = cm.parseJSON(params); 3432 if (params) { 3433 options = cm.merge(options, params); 3434 } 3435 new App.FileInput(options); 3436 }); 3437 /* 3438 * Multiple file upload element 3439 */ 3440 Collector.add('App.MultipleFileInput', function (node) { 3441 var options = {'node' : node}; 3442 var params = node.getAttribute('data-config'); 3443 params = cm.parseJSON(params); 3444 if (params) { 3445 options = cm.merge(options, params); 3446 } 3447 new App.MultipleFileInput(options); 3448 3449 }); 3450 /* 3451 * Image file upload element 3452 */ 3453 Collector.add('App.ImageInput', function (node) { 3454 new App.ImageInput({'node' : node}); 3455 }); 3456 3457}(); 3458 3459 3460!function ($) { 3461 Collector.add('App.FontManager.GoogleFontForm', function (node) { 3462 var nodes = cm.getNodes(node); 3463 nodes = nodes['AppFontManagerGoogleFontForm']; 3464 var preview = function (select, value) { 3465 if (!value || typeof value === 'object') { 3466 nodes['preview-box'].style.fontFamily = ''; 3467 } else { 3468 nodes['preview-link'].setAttribute('href', 'https://fonts.googleapis.com/css?family=' + value); 3469 nodes['preview-box'].style.fontFamily = value; 3470 } 3471 }; 3472 cm.find('Com.Select', 'title', node, function (classObject) { 3473 preview(classObject, classObject.get()); 3474 classObject.addEvent('onChange', preview); 3475 }); 3476 }); 3477}(); 3478 3479 3480 3481 3482!function () { 3483 /* Callbacks of ReCaptcha Adapter for Mod.ElementReCaptcha */ 3484 window.ModElementReCaptchaCallback = function(value){ 3485 new cm.Finder('Mod.ElementReCaptcha', null, null, function(controller){ 3486 controller.set(value).validate(); 3487 }); 3488 }; 3489 3490 window.ModElementReCaptchaExpiredCallback = function(value){ 3491 new cm.Finder('Mod.ElementReCaptcha', null, null, function(controller){ 3492 controller.set('').validate(); 3493 }); 3494 }; 3495 3496 /* Activate Form Elements left sidebar tab*/ 3497 Collector.add('form-manager-active', function (node) { 3498 var lasttab; 3499 cm.addEvent(node, 'click', function (e) { 3500 cm.find('App.Sidebar', 'app-sidebar', null, function (classObject) { 3501 if(classObject.getTab()=='form-manager'){ 3502 classObject.setTab(lasttab); 3503 node.innerHTML=node.getAttribute('data-title'); 3504 }else{ 3505 lasttab = classObject.getTab(); 3506 classObject.setTab('form-manager'); 3507 node.innerHTML=node.getAttribute('data-title-close'); 3508 } 3509 }); 3510 }); 3511 cm.find('App.Sidebar', 'app-sidebar', null, function (classObject) { 3512 classObject.addEvent('onTabHide', function (tabset, data) { 3513 3514 }); 3515 }); 3516 }); 3517// Collector.add('App.FormManager.FileUploader', function (node) { 3518// var nodes = cm.getNodes(node); 3519// var display = function () { 3520// nodes['App']['FormManager']['Multiple']['maxcount'].style.display = node.checked ? '' : 'none'; 3521// }; 3522// cm.addEvent(node, 'click', display); 3523// display(); 3524// }); 3525 3526 Collector.add('autocomplete-checkbox', function (node) { 3527 var func = function(checked){ 3528 var multiple = cm.getByName('general[multiple]'); 3529 var dl = cm.getParentByTagName('dl', multiple[0]); 3530 if (checked) { 3531 cm.addClass(dl, 'display-none'); 3532 } else { 3533 cm.removeClass(dl, 'display-none'); 3534 } 3535 }; 3536 3537 cm.addEvent(node, 'change', function(element, value){ 3538 func(node.checked); 3539 }); 3540 func(node.checked); 3541 }); 3542 3543 Collector.add('module_form', function (node) { 3544 var options = {}; 3545 var params = node.dataset.config; 3546 if (params) { 3547 options = cm.merge(options, JSON.parse(params)); 3548 } 3549 new Mod.Form({ 3550 'node': node, 3551 'events': { 3552 'onSubmit': function (classObject, eventData) { 3553 Collector.destruct(node); 3554 classObject.destruct(); 3555 Request.send(eventData['action'], eventData['data'], 'post', { 'node': node}, {'overlay': true }); 3556 }, 3557 'onReset': function (classObject, eventData) { 3558 Collector.destruct(node); 3559 classObject.destruct(); 3560 Request.send(eventData['action'], { }, 'get', { 'node': node }); 3561 } 3562 } 3563 }); 3564 }); 3565 3566 Collector.add('mod_element-autocomplete', function (node) { 3567 var options = { 3568 'input': node, 3569 'clearOnEmpty': false, 3570 'showListOnEmpty' : true, 3571 'data': [], 3572 }; 3573 3574 var params = node.getAttribute('data-options'); 3575 params = cm.parseJSON(params); 3576 if (params) { 3577 options = cm.merge(options, params); 3578 } 3579 new Com.Autocomplete(options); 3580 }); 3581 3582 Collector.add('mod_element-wizard', function (node) { 3583 new Mod.ElementWizard({'node': node}); 3584 }); 3585 3586 Collector.add('mod_element-checkbox', function (node) { 3587 var el = new Mod.ElementCheckbox({'node': node}); 3588 el.validateValue = function(){ 3589 var that = this, 3590 data = { 3591 'value' : that.get(), 3592 'type' : null, 3593 'valid' : true 3594 }; 3595 if(that.params['required'] && !that.get()){ 3596 data['type'] = 'required'; 3597 data['valid'] = false;
3598 return data; 3599 } 3600 return data; 3601 }; 3602 }); 3603 Collector.add('mod_element-button', function (node) { 3604 if(node.getAttribute('type')=='submit'){ 3605 var form = cm.getParentByTagName('form', node); 3606 cm.addEvent(form, 'submit', function (e) { 3607 if(!e.defaultPrevented) { 3608 setTimeout(function () { 3609 if (!window.overlay) { 3610 window.overlay = new Com.Overlay(); 3611 } else { 3612 if (!window.overlay.isOpen) { 3613 window.overlay.open(true); 3614 } 3615 } 3616 }, 100); 3617 } 3618 }); 3619 } 3620 }); 3621 3622 Collector.add('mod_element-datepicker', function (node) { 3623 new Mod.ElementDatePicker({'node': node}); 3624 }); 3625 3626 Collector.add('mod_element-captcha', function (node) { 3627 new Mod.ElementCaptcha({'node': node}); 3628 }); 3629 3630 Collector.add('mod_element-recaptcha', function (node) { 3631 new Mod.ElementReCaptcha({'node': node}); 3632 }); 3633 3634 Collector.add('mod_element-fileuploader', function (node) { 3635 new Mod.ElementFileUploader({'node': node}); 3636 }); 3637 3638 Collector.add('mod_element-multicheckbox', function (node) { 3639 new Mod.ElementMultiCheckbox({'node': node}); 3640 }); 3641 3642 Collector.add('mod_element-password', function (node) { 3643 new Mod.ElementPassword({'node': node}); 3644 }); 3645 3646 Collector.add('mod_element-radiobutton', function (node) { 3647 new Mod.ElementRadioButton({'node': node}); 3648 }); 3649 3650 Collector.add('mod_element-select', function (node) { 3651 new Mod.ElementSelect({'node': node}); 3652 }); 3653 3654 Collector.add('mod_element-text', function (node) { 3655 new Mod.ElementText({'node': node}); 3656 }); 3657 3658 Collector.add('mod_element-textarea', function (node) { 3659 new Mod.ElementTextArea({'node': node}); 3660 }); 3661 3662 Collector.add('mod_element-wysiwyg', function (node) { 3663 new Mod.ElementWysiwyg({'node': node}); 3664 }); 3665 Collector.add('mod_element-fieldset', function (node) { 3666 isElementMultiFieldDirty = false; 3667 new Mod.ElementMultiField({ 3668 'node': node, 3669 'events': { 3670 'onEnableEditing': function (element, value) { 3671 isElementMultiFieldDirty = true; 3672 }, 3673 'onDisableEditing': function (element, value) { 3674 if(isElementMultiFieldDirty) { 3675 isElementMultiFieldDirty = false; 3676 cm.find('Mod.Form', null, null, function (form) { 3677 cm.find('App.Block', null, null, function (classObject) { 3678 if (classObject.params['positionId'] == form.params['positionId']) { 3679 window.activeBlock = classObject; 3680 cm.find('App.Editor', 'app-editor', null, function (editor) { 3681 editor.updateRequest(window.activeBlock); 3682 }); 3683 } 3684 }); 3685 }); 3686 } 3687 } 3688 } 3689 }); 3690 }); 3691 3692 Collector.add('elements-rules', function (node) { 3693 3694 var container = cm.Node('div'); 3695 cm.insertAfter(container,node); 3696 node.setAttribute('type','hidden'); 3697 3698 var options = { 3699 'name' : node.name, 3700 'node' : container, 3701 'container' : container, 3702 'renderStructure' : true, 3703 'embedStructureOnRender' : true, 3704 'templateAttributeReplace': false, 3705 'renderItems' : 0, 3706 'events' : { 3707 'onItemAdd': function(that, item){ 3708 3709 var container = { 3710 'element':'', 3711 'opers':'', 3712 'condition':'', 3713 'logic': cm.node('div', {'class':'col'}), 3714 }; 3715 item['field'].appendChild( 3716 cm.node('div', {'class':'cols three clear'}, 3717 container['element'] = cm.node('div', {'class':'col'}),
3718 container['opers'] = cm.node('div', {'class':'col'}), 3719 container['condition'] = cm.node('div', {'class':'col'}) 3720 ) 3721 ); 3722 3723 var element; 3724 3725 var elements = new Com.Select({ 3726 'name': 'element', 3727 'node': container['element'], 3728 'options' : that.params.rules.elements, 3729 'events' : { 3730 'onChange': function (select, value) { 3731 if(element){ 3732 if (element.nodeType) { 3733 cm.remove(element); 3734 }else{ 3735 container['condition'] = element.getNodes('container'); 3736 Collector.destruct(container['condition']); 3737 cm.clearNode(container['condition']); 3738 } 3739 } 3740 3741 switch (that.params.rules.elements[value]['type']) { 3742 case 'text': 3743 case 'hidden': 3744 case 'date': 3745 element = cm.node('input', { 3746 'name':'value', 3747 'type': 'text', 3748 'placeholder':'Value' 3749 }); 3750 if(item.value){ 3751 element.setAttribute('value',item.value); 3752 } 3753 container['condition'].appendChild(element); 3754 break; 3755 3756 case 'multi_checkbox': 3757 case 'radio': 3758 case 'select': 3759 element = new Com.Select({ 3760 'name':'value', 3761 'node': container['condition'], 3762 'options' : that.params.rules.elements[value]['options'], 3763 }); 3764 if(item.value){ 3765 element.set(item.value); 3766 } 3767 break; 3768 3769 case 'checkbox': 3770 element = new Com.Select({ 3771 'name':'value', 3772 'node': container['condition'], 3773 'options' : [ 3774 {'value' : 'checked', 'text' : 'Checked'}, 3775 {'value' : 'unchecked', 'text' : 'Unchecked'}, 3776 ], 3777 }); 3778 if(item.value){ 3779 element.set(item.value); 3780 } 3781 break; 3782 3783 default: 3784 break; 3785 } 3786 } 3787 } 3788 }); 3789 /* 3790 var logic = new Com.Select({ 3791 'name': 'logic', 3792 'node' : container['logic'], 3793 'options': [ 3794 {value: 'AND', text: 'AND'}, 3795 {value: 'OR', text: 'OR'}, 3796 ], 3797 }); 3798 */ 3799 var opers = new Com.Select({ 3800 'name': 'opers',
3801 'node' : container['opers'], 3802 'options': [ 3803 {value: 'EQ', text: 'equal to'}, //EQUAL TO 3804 {value: 'NE', text: 'not equal to'}, //NOT EQUAL TO 3805 {value: 'GT', text: 'less then'}, //LESS THAN 3806 {value: 'GTE', text: 'less than or equal to'},//LESS THAN OR EQUAL TO 3807 {value: 'LT', text: 'greater than'}, //GREATER THAN 3808 {value: 'LTE', text: 'greater than or equal to'},//GREATER THAN OR EQUAL TO 3809 {value: 'EXP', text: 'custom'},//Javascript expression 3810 ], 3811 }); 3812 if(item.opers){ 3813 opers.set(item.opers); 3814 } 3815 elements.set(item.element); 3816 elements.triggerEvent('onChange', elements.get()); 3817 } 3818 } 3819 }; 3820 3821 var params = node.dataset.config; 3822 if (params) { 3823 options = cm.merge(options, JSON.parse(params)); 3824 } 3825 var multifield = new Com.MultiField(options); 3826 3827 if(node.value){ 3828 var values = JSON.parse(node.value); 3829 cm.forEach(values, function (value, idx) { 3830 multifield.addItem({element: value.element, opers: value.opers, value: value.value}); 3831 }); 3832 } 3833 }, function (node) { 3834 cm.find('Com.MultiField', node.name, null, function (classObject) { 3835 var results = []; 3836 var items = classObject.getItems(); 3837 cm.forEach(items, function (item, idx) { 3838 Collector.destruct(item.content); 3839 results.push(cm.getFDO(item.content)); 3840 }); 3841 classObject.clear(); 3842 node.value = JSON.stringify(results); 3843 }); 3844 }); 3845 3846 Collector.add('elements-visibility-rules-form', function (node) { 3847 var options = {}; 3848 var params = node.dataset.config; 3849 if (params) { 3850 options = cm.merge(options, JSON.parse(params)); 3851 } 3852 3853 var blocks = {}; 3854 3855 function init(){ 3856 cm.find('App.Editor', 'app-editor', null, function (classObject) { 3857 classObject.addEvent('onExpand',updateVisibility); 3858 classObject.addEvent('onCollapse', updateVisibility); 3859 classObject.addEvent('onProcessEnd', prepare); 3860 }); 3861 } 3862 function compare(opers, source, target){ 3863 switch(opers){ 3864 case 'EXP': 3865 var match = target.match(/^DIFFDATE\([\s]*[\'\"%]+(.+)[\'\"%]+[\s]*,[\s]*[\'\"%]+(.+)[\'\"%]+[\s]*,[\s]*[\'\"%](.+)[\'\"%][\s]*,[\s]*[\'\"%]+(.+)[\'\"%]+[\s]*\)$/); 3866 if(match){ 3867 var now = Date.now(); 3868 var value = Date.parse(source); 3869 if (match[1] != 'NOW') { 3870 now = Date.parse(match[1]); 3871 } 3872 if (match[2] != 'VALUE') { 3873 value = Date.parse(match[2]); 3874 } 3875 var diff = (now-value)/365 / 24 / 60 / 60 / 1000; 3876 switch (match[3]) { 3877 case 'GT': 3878 return diff > match[4]; 3879 break; 3880 case 'GTE': 3881 return diff >= match[4]; 3882 break; 3883 case 'NE': 3884 return diff != match[4]; 3885 case 'EQ': 3886 return diff == match[4]; 3887 break; 3888 case 'LTE': 3889 return diff <= match[4]; 3890 break; 3891 case 'LT': 3892 return diff < match[4]; 3893 break; 3894 } 3895 } 3896 break; 3897 case 'EQ': 3898 return source==target; 3899 break; 3900 case 'NE': 3901 return source!=target; 3902 break; 3903 case 'GT': 3904 return source>target; 3905 break; 3906 case 'GTE': 3907 return source>=target; 3908 break; 3909 case 'LT': 3910 return source<target; 3911 break; 3912 case 'LTE': 3913 return source<=target; 3914 break; 3915 } 3916 return false;
3917 } 3918 function prepare(){ 3919 blocks = []; 3920 cm.find('App.Block', null, node, function (classObject) { 3921 if (classObject.params.type == 'form-manager' || classObject.params.type == 'profile-form' ){ 3922 3923 if(classObject.params.visibility.element==undefined || classObject.params.visibility.element.length==0){ 3924 return; 3925 } 3926 blocks[classObject.params.blockId]={ 3927 block : classObject, 3928 rules : [], 3929 hide: false, 3930 cond: 'AND' 3931 }; 3932 cm.forEach(classObject.params.visibility.element, function (value, idx) { 3933 var elements = cm.getByName(value.element); 3934 if(elements && elements.length > 0){ 3935 if (elements.length > 1){ 3936 if ('input' == elements.item(0).tagName.toLowerCase()) { 3937 switch (elements.item(0).type) { 3938 case 'checkbox': 3939 cm.forEach(elements, function(element){ 3940 if (element.value == value.value){ 3941 blocks[classObject.params.blockId]['rules'].push({ 3942 'element': element, 3943 'multiple': true, 3944 'opers': value.opers, 3945 'value': value.value, 3946 'cond': classObject.params.visibility.element_conditions 3947 }); 3948 } 3949 3950 cm.addEvent(element, 'change', updateVisibility) 3951 }) 3952 break; 3953 3954 case 'radio': 3955 cm.forEach(elements, function(element){ 3956 if (element.value == value.value){ 3957 blocks[classObject.params.blockId]['rules'].push({ 3958 'element': element, 3959 'opers': value.opers, 3960 'value': value.value, 3961 'cond': classObject.params.visibility.element_conditions 3962 }); 3963 } 3964 3965 cm.addEvent(element, 'change', updateVisibility) 3966 }) 3967 3968 break; 3969 3970 default: 3971 //cm.addEvent(element, 'change', updateVisibility) 3972 break; 3973 } 3974 } 3975 if ('select' == elements.item(0).tagName.toLowerCase()) { 3976 var element = elements.item(0); 3977 blocks[classObject.params.blockId]['rules'].push({ 3978 'element': element, 3979 'opers': value.opers, 3980 'value': value.value, 3981 'cond': classObject.params.visibility.element_conditions 3982 }); 3983 cm.find('Com.Select', element.name, null, function (classObject) { 3984 classObject.addEvent('onChange', updateVisibility); 3985 }); 3986 } 3987 } else { 3988 var element = elements.item(0); 3989 blocks[classObject.params.blockId]['rules'].push({ 3990 'element': element, 3991 'opers': value.opers, 3992 'value': value.value, 3993 'cond': classObject.params.visibility.element_c
3993onditions 3994 }); 3995 3996 switch (element.tagName.toLowerCase()) { 3997 case 'input': 3998 switch (element.type) { 3999 case 'hidden': 4000 cm.find('Com.Datepicker', element.name, null, function (classObject) { 4001 classObject.addEvent('onChange', updateVisibility); 4002 }); 4003 break; 4004 4005 default: 4006 cm.addEvent(element, 'change', updateVisibility) 4007 break; 4008 4009 } 4010 break; 4011 4012 case 'select': 4013 cm.find('Com.Select', element.name, null, function (classObject) { 4014 classObject.addEvent('onChange', updateVisibility); 4015 }); 4016 break; 4017 4018 default: 4019 break; 4020 } 4021 } 4022 }else{ 4023 //hide if element absent 4024 blocks[classObject.params.blockId].hide = true; 4025 } 4026 }); 4027 } 4028 }); 4029 } 4030 function updateVisibility(){ 4031 cm.forEach(blocks, function (block, idx) { 4032 var showforce = false; 4033 cm.find('App.Editor', 'app-editor', null, function (classObject) { 4034 showforce = classObject.isExpanded; 4035 }); 4036 4037 var show = false; 4038 if(showforce){ 4039 show = true; 4040 }else{ 4041 if(block.hide){ 4042 show = false; 4043 }else{ 4044 var result,exit = false; 4045 cm.forEach(block.rules, function (value, idx) { 4046 if(exit){ 4047 return; 4048 } 4049 switch (value.element.type) { 4050 case 'text': 4051 case 'hidden': 4052 result = compare(value.opers, value.element.value, value.value) 4053 break; 4054 4055 case 'checkbox': 4056 result = compare(value.opers, value.element.checked, (value.value == 'checked')); 4057 if (value.hasOwnProperty('multiple') && value.multiple){ 4058 result = !result; 4059 } 4060 break; 4061 4062 case 'radio': 4063 if (value.element.value == value.value) { 4064 result = compare(value.opers, value.element.checked, true); 4065 } 4066 break; 4067 } 4068 4069 if(value.element.tagName.toLowerCase()=='select') { 4070 cm.find('Com.Select', value.element.name, null, function(classObject){ 4071 if (cm.isArray(value.value)) { 4072 result = false;
4073 cm.forEach(value.value, function (item) { 4074 mresult = compare(value.opers, classObject.get(), item); 4075 if(mresult){ 4076 result = true; 4077 } 4078 }); 4079 }else{ 4080 result = compare(value.opers, classObject.get(), value.value); 4081 } 4082 }); 4083 } 4084 4085 if(result) { 4086 //check is element hidden 4087 result = !cm.isParentByClass('is-hidden', value.element) 4088 } 4089 4090 if(!result){ 4091 if(value.cond=='AND' || value.cond == undefined){ 4092 exit = true; 4093 4094 } 4095 }else{ 4096 if(value.cond=='OR'){ 4097 exit = true; 4098 4099 } 4100 } 4101 }); 4102 show = result; 4103 } 4104 } 4105 block.block.toggleVisibility(show); 4106 var blockNode = block.block.node; 4107 if (!show) { 4108 cm.forEach(blockNode.querySelectorAll('input, select, textarea'), function(input) { 4109 if (!input.dataset.visibilityDisabled) { 4110 input.dataset.visibilityDisabled = 'true'; 4111 input.disabled = true; 4112 } 4113 }); 4114 } else { 4115 cm.forEach(blockNode.querySelectorAll('[data-visibility-disabled]'), function(input) { 4116 delete input.dataset.visibilityDisabled; 4117 input.disabled = false; 4118 }); 4119 } 4120 }); 4121 } 4122 4123 init(); 4124 prepare(); 4125 updateVisibility(); 4126 4127 }, null, 1000); 4128}(); 4129 4130 4131 4132 4133(function() { 4134 if( typeof CKEDITOR !== "undefined" ) { 4135 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'helpbox' : ',helpbox'; 4136 } 4137 4138 Collector.add('helpbox', function(node){ 4139 var params = node.getAttribute('data-content'); 4140 if(params){ 4141 cm.addEvent(node, 'click', function(e){ 4142 var title = node.getAttribute('data-title'); 4143 new Com.Dialog({ 4144 title : title?unescape(title):'', 4145 zIndex : 9999, 4146 closeBtn : true, 4147 content : cm.Node('div', { 4148 innerHTML: unescape(node.getAttribute('data-content')) 4149 }) 4150 }).open(); 4151 cm.preventDefault(e); 4152 }); 4153 } 4154 }); 4155})(); 4156 4157 4158 4159!function() { 4160 Collector.add('module_rollover_tabs', function (node) { 4161 new App.ModuleRolloverTabs({'node' : node}); 4162 }); 4163}(); 4164 4165 4166 4167!function ($) { 4168 if( typeof CKEDITOR === "undefined" ) { 4169 return; 4170 } 4171 4172 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'control' : ',control'; 4173 4174 cm.onReady(function () { 4175 cm.addEvent(document.body, 'dblclick', function (e) { 4176 cm.find('App.Sidebar', null, null, function(sidebar){ 4177 if(!sidebar.isExpanded){ 4178 cm.find('App.Lock', null, null, function(lock){ 4179 lock.startRequest(); 4180 }); 4181 } 4182 }); 4183 cm.preventDefault(e); 4184 var element = cm.getEventTarget(e); 4185 var nodes = cm.getByClass('app-mod__richeditor'); 4186 cm.forEach(nodes, function (node) { 4187 if (node !== element) { 4188 if (!cm.isParent(node, element)) { 4189 cm.forEach(CKEDITOR.instances, function (instance) { 4190 //instance.fire('blur'); 4191 }); 4192 return; 4193 } 4194 } 4195 var typeBlock = node.getAttribute('data-element'); 4196 if ('block-content' == typeBlock || 'inlineEditor' == typeBlock) { 4197 if (node.getAttribute('contenteditable') 4198 && node.getAttribute('contenteditable') == 'true') { 4199 return; 4200 } 4201 4202 // htmlspecialchars decode js 4203 var original = node.getAttribute('data-original'); 4204 var textArea = document.createElement('textarea'); 4205 textArea.innerHTML = JSON.parse(original); 4206 node.innerHTML = textArea.value; 4207 4208 node.setAttribute('contenteditable', true); 4209 Collector.destruct(node); 4210 var ckeditor = CKEDITOR.inline(node); 4211 ckeditor.on('destroy', function (ev) { 4212 cm.find('App.Sidebar', null, null, function(sidebar){ 4213 if(!sidebar.isExpanded){ 4214 cm.find('App.Lock', null, null, function(lock){ 4215 lock.stopRequest(); 4216 }); 4217 } 4218 }); 4219 }); 4220 ckeditor.on('instanceReady', function (ev) { 4221 4222 ev.editor.focus(); 4223 ev.editor.on('blur', function (ev) { 4224 if (ev.editor.checkDirty()) { 4225 ev.editor.fire('save'); 4226 } 4227 node.setAttribute('contenteditable', false); 4228 ev.editor.destroy(); 4229 Collector.construct(node); 4230 }); 4231 4232 if ('block-content' == typeBlock) { 4233 ev.editor.on('save', function (ev) { 4234 if (ev.editor.checkDirty()) { 4235 ev.editor.updateElement(); 4236 4237 var content = ev.editor.getData(); 4238 // send the data to backend 4239 var params = {'params': {'content': content}}; 4240 4241 node.setAttribute('data-original', JSON.stringify(content)); 4242 Request.send(node.getAttribute('data-block-partial-url'), params, 'post', {'render': false}); 4243 } 4244 }); 4245 ev.editor.on('paste', function (event) { 4246 if (event.data['type'] == 'html' || event.data['type'] == 'text') { 4247 // clear from all data attributes 4248 var reg = new RegExp('data-.*|data-block.*|data-element|data-com.*', 'i'); 4249 var fragment = CKEDITOR.htmlParser.fragment.fromHtml(event.data['dataValue']), 4250 writer = new CKEDITOR.htmlParser.basicWriter(); 4251 fragment.forEach(function (node) { 4252 cm.forEach(node.attributes, function (item, attr) { 4253 var check = reg.exec(attr); 4254 if (check && check.length) { 4255 delete node.attributes[check[0]]; 4256 } 4257 }); 4258 }); 4259 4260 fragment.writeHtml(writer); 4261 event.data['dataValue'] = writer.getHtml(); 4262
4263 var value = cm.Node('div', {'innerHTML': event.data['dataValue']}); 4264 4265 var menu = value.querySelectorAll('.pt__menu.menu, .drag'); 4266 if (menu.length) { 4267 cm.forEach(menu, function (item) { 4268 item.parentNode.removeChild(item); 4269 }); 4270 } 4271 4272 var inner = value.querySelectorAll('.inner'); 4273 4274 //remove classes 4275 var classes = value.querySelectorAll('.app__block-container, .inner, .pt__dnd-area, .is-available, .app-mod__richeditor'); 4276 if (classes.length) { 4277 cm.forEach(classes, function (item, i) { 4278 cm.removeClass(item, 'app__block-container'); 4279 cm.removeClass(item, 'inner'); 4280 cm.removeClass(item, 'pt__dnd-area'); 4281 cm.removeClass(item, 'is-available'); 4282 cm.removeClass(item, 'pt__dnd-area'); 4283 cm.removeClass(item, 'app__module'); 4284 cm.removeClass(item, 'app-mod__richeditor'); 4285 }) 4286 } 4287 4288 event.data['dataValue'] = value.innerHTML; 4289 } 4290 }); 4291 } 4292 if ('inlineEditor' == typeBlock) { 4293 ev.editor.on('save', function () { 4294 if (ev.editor.checkDirty()) { 4295 ev.editor.updateElement(); 4296 node.setAttribute('data-original', JSON.stringify(ev.editor.getData())); 4297 4298 // send the data to backend 4299 $.ajax({ 4300 type: "POST", 4301 url: window.config.url + '/admin/inline-editor', 4302 data: { 4303 id: node.getAttribute('data-id'), 4304 entity: node.getAttribute('data-entity'), 4305 type: node.getAttribute('data-type'), 4306 value: ev.editor.getData() 4307 }, 4308 success: function (response) { 4309 var parent = $(ev.editor).parent(); 4310 if (parent.find('div.form')) { 4311 parent.find('div.form').remove(); 4312 } 4313 //replace source container 4314 if (response.result) { 4315 var updateContent = response.details.content; 4316 ev.editor.setData(updateContent); 4317 ev.editor.resetDirty(); 4318 // Bind events and other setting 4319 Collector.construct(node); 4320 } else { 4321 if (response.message) { 4322 var str = response.message; 4323 if (cm.isArray(str)) { 4324 str = str.join('</li><li>'); 4325 } 4326 parent.append( 4327 '<div class="form">' + 4328 '<dl class="error">' + 4329 '<dd>' + 4330 '<ul class="hint">Item not changed' + 4331 '<li>' + str + '</li>' + 4332 '</ul>' + 4333 '</dd>' + 4334 '</dl>' + 4335 '</div>'); 4336 } 4337 } 4338 } 4339 }) 4340 } 4341 }); 4342 } 4343 }); 4344 } else { 4345 cm.forEach(CKEDITOR.instances, function (instance) { 4346 instance.fire('blur'); 4347 instance.destroy(); 4348 }); 4349 } 4350 }); 4351 }); 4352 }); 4353 4354}(window.jQuery); 4355 4356 4357 4358(function() { 4359 if( typeof CKEDITOR !== "undefined" ) { 4360 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'lightbox' : ',lightbox'; 4361 } 4362 4363 Collector.add('lightBox', function(node){ 4364 if(node.getAttribute('data-text')){ 4365 cm.addEvent(node, 'click', function(e){ 4366 new Com.Dialog({ 4367 title : node.nodeValue, 4368 zIndex : 9999, 4369 closeBtn : true,
4370 content : cm.Node("div", { 4371 innerHTML: unescape(node.getAttribute('data-text')) 4372 }) 4373 }).open(); 4374 cm.preventDefault(e); 4375 }); 4376 } 4377 },function(node){ 4378 cm.removeEvent(node, 'click'); 4379 }); 4380 4381})(); 4382 4383 4384 4385!function () { 4386 4387 Collector.add('select', function(node) { 4388 if (node.name === 'selectmodule') { 4389 var select = Com.GetSelect('selectmodule'); 4390 if (select) { 4391 select.addEvent('onChange', function(select, active) { 4392 Request.send(node.getAttribute('data-url'), {'module': active}, 'post', {}, {'overlay': false}); 4393 }); 4394 } 4395 } 4396 }); 4397 4398 Request.add('nm-set-instances', function (details, context) { 4399 var instance = Com.GetSelect('selectinstance'); 4400 if (cm.isEmpty(details.instances.items)) { 4401 instance.removeOptionsAll(); 4402 instance.addOption('none', cm.getEl('selectinstance').getAttribute('data-text')); 4403 instance.set('none'); 4404 return; 4405 } 4406 instance.enable(); 4407 if (instance) { 4408 if (instance.getOptionsAll()) { 4409 instance.removeOptionsAll(); 4410 } 4411 cm.forEach(details.instances.items, function (item, key) { 4412 instance.addOption(key, item); 4413 }); 4414 4415 var all = instance.getOptionsAll(); 4416 if (all.length) { 4417 instance.set(all[0].value); 4418 } 4419 4420 cm.getByName('type').item(0).value = details.instances.type; 4421 } 4422 }); 4423 4424}(); 4425 4426 4427 4428!function() { 4429 Collector.add('export-button', function (node) { 4430 cm.addEvent(node, 'click', function (e) { 4431 var params = {}; 4432 cm.find('Com.Gridlist', node.getAttribute('data-gridlist-name'), null, function (classObject) { 4433 var action = classObject.getCurrentAction(); 4434 params = action['params']; 4435 }); 4436 var url = e.currentTarget.getAttribute('href'); 4437 if (url) { 4438 Request.send(url, params, 'get', {'node': node}); 4439 } 4440 cm.preventDefault(e); 4441 }); 4442 }); 4443 Request.add('autosubmit', function (details, context) { 4444 document.write(details['content']); 4445 setTimeout(function () {for (var i = 0; i < document.forms.length; i++) {document.forms[i].submit();}}, 1000) 4446 }); 4447}(); 4448 4449 4450 4451 4452!function () { 4453 4454 cm.define('App.FormMenuSettings', { 4455 'extend' : 'Com.AbstractController', 4456 'params': { 4457 'node': cm.Node('div') 4458 } 4459 }, function (params) { 4460 var that = this; 4461 if(!that.components) { 4462 that.components = {}; 4463 } 4464 4465 // Call parent class construct 4466 Com.AbstractController.apply(that, arguments); 4467 }); 4468 4469 cm.getConstructor('App.FormMenuSettings', function(classConstructor, className, classProto) { 4470 var _inherit = classProto._inherit; 4471 var findSelect = function (node, handler) { 4472 return cm.find('Com.Select', null, node, handler); 4473 }; 4474 4475 classProto.renderViewModel = function() { 4476 var that = this; 4477 4478 _inherit.prototype.renderViewModel.apply(that, arguments); 4479 4480 var nodes = that.nodes; 4481 4482 var pages = nodes.display['pages']; 4483 var subpage = nodes.display['subpage']; 4484 var display = nodes.display['root']; 4485 4486 findSelect(display, function (element) { 4487 that.components['root'] = element; 4488 4489 element.addEvent('onChange', function (select, value) { 4490 if (value == 'subpage') { 4491 cm.removeClass(subpage, 'display-none'); 4492 } else { 4493 cm.addClass(subpage, 'display-none'); 4494 } 4495 }); 4496 }); 4497 4498 findSelect(nodes['type'], function (element) { 4499 that.components['type'] = element; 4500 4501 element.addEvent('onChange', function (select, value) { 4502 if (value == 'standart') { 4503 cm.addClass(pages, 'display-none'); 4504 4505 cm.removeClass(display, 'display-none'); 4506 4507 var cRoot = that.components['root']; 4508 cRoot.triggerEvent('onChange', cRoot.get()); 4509 } else if (value == 'custom') { 4510 cm.removeClass(pages, 'display-none'); 4511 4512 cm.addClass(display, 'display-none'); 4513 cm.addClass(subpage, 'display-none'); 4514 } 4515 }); 4516 4517 element.triggerEvent('onChange', element.get()); 4518 }); 4519 4520 findSelect(nodes.style, function (element) { 4521 that.components['style'] = element; 4522 4523 var dataOptions = []; 4524 4525 function getOptions(type) { 4526 if (cm.isEmpty(dataOptions)) { 4527 var attr = element.getStackNode().getAttribute('data-options'); 4528 dataOptions = JSON.parse(attr); 4529 } 4530 4531 if (dataOptions && type in dataOptions) { 4532 return dataOptions[type]; 4533 } 4534 4535 return []; 4536 } 4537 4538 element.setOptionByType = function (type, selected) { 4539 element.removeOptionsAll(); 4540 element.addOption('', '-- None --'); 4541 4542 var options = getOptions(type); 4543 if (options) { 4544 cm.forEach(options, function (item, i) { 4545 element.addOption(item['value'], item['text']); 4546 }); 4547 4548 if (selected != null) { 4549 element.set(selected); 4550 } 4551 } 4552 }; 4553 }); 4554 4555 findSelect(nodes.orientation, function (element) { 4556 var additional = nodes.vertical.additional; 4557 4558 that.components['orientation'] = element; 4559 4560 var style = { 4561 'element': that.components['style'], 4562 'preview': {}, 4563 }; 4564 4565 var initValue = element.get(); 4566 style['preview'][initValue] = style['element'].get(); 4567 style['element'].addEvent('onSelect', function (self, value) { 4568 style['preview'][initValue] = self.get(); 4569 }); 4570 4571 element.addEvent('onChange', function (self, value) { 4572 var selected = ''; 4573 if (style['preview'].hasOwnProperty(value)) { 4574 selected = style['preview'][value]; 4575 } 4576 4577 style['element'].setOptionByType(value, selected); 4578 4579 if (value == 'horizontal') { 4580 cm.addClass(additional, 'display-none'); 4581 } else if (value == 'vertical') { 4582 cm.removeClass(additional, 'display-none'); 4583 } 4584 }); 4585 4586 element.triggerEvent('onChange', element.get()); 4587 }); 4588 } 4589 }); 4590 4591 Collector.add('app.menu-preview', function(node) { 4592 new App.MenuConstructorPreview({'node':node}); 4593 }, null, 100); 4594 4595 Collector.add('app.menu-designer', function(node) { 4596 new App.MenuConstructor({'node':node}); 4597 }, null, 100); 4598 4599 Collector.add('form_menu_settings', function (node) { 4600 new App.FormMenuSettings({'node': node}); 4601 }, null, 99); 4602 4603 Collector.addEvent('onConstruct', function () { 4604 Part.Menu(); 4605 }); 4606 4607 Collector.add('module-menu', function (node) { 4608 new App.ModuleMenu({'node': node}); 4609 }); 4610 4611 Collector.add('module-menu.style', function (node) { 4612 new Module.Menu({'node': node}); 4613 }); 4614 4615 Collector.add('menu', function (node) { 4616 new Com.Menu({'node': node}); 4617 }); 4618 4619}(); 4620 4621 4622 4623 4624!function() { 4625 Collector.add('module-search', function(node) { 4626 new App.SearchBox({ 4627 'node' : node 4628 }); 4629 }); 4630}(); 4631 4632 4633 4634cm.define('App.FormSeoSettings', { 4635 'modules': [ 4636 'Params', 4637 'Events', 4638 'Langs', 4639 'DataConfig', 4640 'DataNodes', 4641 ], 4642 'events': [ 4643 'onRender' 4644 ], 4645 'params': { 4646 'node': cm.Node('div'), 4647 'name': '' 4648 } 4649}, 4650function (params) { 4651 var that = this; 4652 4653 var init = function () { 4654 that.setParams(params); 4655 that.convertEvents(that.params['events']); 4656 that.getDataNodes(that.params['node']); 4657 that.getDataConfig(that.params['node']); 4658 render(); 4659 that.triggerEvent('onRender'); 4660 }; 4661 4662 var render = function () { 4663 /* metaTitle */ 4664 var metaTitle = function () { 4665 var count = that.nodes['metaTitle'].getAttribute('data-maxLength') - that.nodes['metaTitle'].value.length; 4666 var hintText = that.nodes['metaTitleHint'].getAttribute('data-text'); 4667 var hint = (count < 0) ? '<span style="color:red">'+count + ' ' + hintText+'</span>' : count + ' ' + hintText; 4668 that.nodes['metaTitleHint'].innerHTML = hint; 4669 }; 4670 cm.addEvent(that.nodes['metaTitle'], 'input', metaTitle); 4671 metaTitle(); 4672 4673 /* metaKeywords */ 4674 var metaKeywords = function () { 4675 var count = that.nodes['metaKeywords'].getAttribute('data-maxLength') - that.nodes['metaKeywords'].value.length; 4676 var hintText = that.nodes['metaKeywordsHint'].getAttribute('data-text'); 4677 var hint = (count < 0) ? '<span style="color:red">'+count + ' ' + hintText+'</span>' : count + ' ' + hintText; 4678 that.nodes['metaKeywordsHint'].innerHTML = hint; 4679 }; 4680 cm.addEvent(that.nodes['metaKeywords'], 'input', metaKeywords); 4681 metaKeywords(); 4682 4683 /* metaDescr */ 4684 var metaDescr = function () { 4685 var count = that.nodes['metaDescr'].getAttribute('data-maxLength') - that.nodes['metaDescr'].value.length; 4686 var hintText = that.nodes['metaDescrHint'].getAttribute('data-text'); 4687 var hint = (count < 0) ? '<span style="color:red">'+count + ' ' + hintText+'</span>' : count + ' ' + hintText; 4688 that.nodes['metaDescrHint'].innerHTML = hint; 4689 }; 4690 cm.addEvent(that.nodes['metaDescr'], 'input', metaDescr); 4691 metaDescr(); 4692 }; 4693 4694 4695 /* ******* MAIN ******* */ 4696 4697 init(); 4698 4699}
4699); 4700!function() { 4701 cm.onLoad(function() { 4702 4703 var select = Com.GetSelect('mail[mailer]'); 4704 if (select) { 4705 var toggle = function(select, active) { 4706 4707 var allItems = document.getElementById('fieldset-mail').getElementsByTagName('dl'); 4708 cm.forEach(allItems, function(item) { 4709 if(item.className.length > 0) { 4710 item.style.display = 'none'; 4711 } 4712 }); 4713 var items = cm.getByClass(active, cm.getEl('fieldset-mail')); 4714 cm.forEach(items, function(item) { 4715 item.style.display = ''; 4716 }); 4717 }; 4718 4719 select.addEvents({'onSelect': toggle}); 4720 toggle(select, select.get()); 4721 4722 } 4723 4724 var select = Com.GetSelect('cookiesnotice[style]'); 4725 if (select) { 4726 var toggle2 = function(select, active) { 4727 var custom = cm.getByAttr('data-node','cookiesnotice[custom]'); 4728 if (custom){ 4729 custom = custom[0]; 4730 if (active == 'custom') { 4731 custom.style.display = ''; 4732 } else { 4733 custom.style.display = 'none'; 4734 } 4735 } 4736 }; 4737 select.addEvents({'onSelect': toggle2}); 4738 toggle2(select, select.get()); 4739 } 4740 }); 4741 4742 Collector.add('form_seo_settings', function (node) { 4743 new App.FormSeoSettings({'node' : node}); 4744 }); 4745}(); 4746 4747 4748 4749!function ($) { 4750 4751 Collector.add('splash', function (node) { 4752 var splash_type = node.getAttribute('data-splash-type'); 4753 var splash_url = node.getAttribute('data-splash-url'); 4754 var splash_iframe = node.getAttribute('data-splash-iframe'); 4755 if (splash_type === 'popup' && splash_iframe === 'false') { 4756 $.ajax( 4757 { 4758 'url': splash_url, 4759 'method': 'POST', 4760 'processData': false 4761 } 4762 ).done(function(result) { 4763 var content = cm.Node('div', 4764 { 4765 'innerHTML': result 4766 } 4767 ).querySelector("[data-node='AppTemplate.content']"); 4768 }); 4769 /* 4770 need to test 4771 cm.ajax({ 4772 'method': 'post', 4773 'type': 'json', 4774 'url': splash_url, 4775 'onSuccess': function (responce, load) { 4776 if (load.target.status === 200) { 4777 if (responce.result) { 4778 var content = cm.Node('div',{'innerHTML': responce.result}) 4779 .querySelector("[data-node='AppTemplate.content']"); 4780 } 4781 } 4782 } 4783 }); 4784 */ 4785 } else { 4786 var content = cm.node('iframe', 4787 { 4788 'class' : 'com__dialog__iframe', 4789 'src' : splash_url, 4790 'frameborder': 0 4791 } 4792 ); 4793 } 4794 4795 new Com.Dialog({ 4796 'width': '100%', 4797 'height': '100%', 4798 'indentX' : 72, 4799 'closeButtonOutside': true, 4800 'titleReserve': false, 4801 'closeButton': false, 4802 'documentScroll': false, 4803 'scroll': false, 4804 'className' : 'app__splash__dialog', 4805 'content': content, 4806 'events' : { 4807 'onOpenStart': function() { 4808 Collector.construct(content); 4809 } 4810 } 4811 }).open(); 4812 node.parentNode.removeChild(node); 4813 }); 4814 4815 4816}(window.jQuery); 4817 4818 4819 4820(function ($) { 4821 4822 Collector.add('select', function (node) { 4823 if (node.name === 'general[position]') { 4824 setTimeout(function(){ 4825 var select = Com.GetSelect('general[position]'); 4826 select.addEvent('onChange', function (self, value) { 4827 if ('right' == value || 'left' == value) { 4828 $(cm.getByName('general[width]').item(0)).closest('dl').show(); 4829 $(cm.getByName('general[flexible]').item(0)).closest('dl').hide(); 4830 } else { 4831 $(cm.getByName('general[flexible]').item(0)).closest('dl').show(); 4832 $(cm.getByName('general[width]').item(0)).closest('dl').hide(); 4833 } 4834 }); 4835 4836 select.triggerEvent('onChange', select.get()); 4837 }, 100); 4838 } 4839 }); 4840 4841})(window.jQuery); 4842 4843 4844 4845cm.define('App.TemplateLibrary', { 4846 'modules' : [ 4847 'Params', 4848 'Events', 4849 'Langs', 4850 'DataConfig', 4851 'DataNodes', 4852 'Stack' 4853 ], 4854 'events' : [ 4855 'onRender' 4856 ], 4857 'params' : {
4858 'node' : cm.Node('div'), 4859 'name' : '', 4860 'App.TemplateList' : { 4861 'name' : 'admin_templatelibrary' 4862 } 4863 } 4864}, function(params) { 4865 var that = this; 4866 4867 that.components = {}; 4868 that.nodes = { 4869 'container' : cm.node('div'), 4870 'toolbar' : { 4871 'container' : cm.node('div'), 4872 'filter' : cm.node('form'), 4873 'submit' : cm.node('button') 4874 } 4875 }; 4876 4877 var init = function(){ 4878 that.setParams(params); 4879 that.convertEvents(that.params['events']); 4880 that.getDataNodes(that.params['node']); 4881 that.getDataConfig(that.params['node']); 4882 render(); 4883 that.addToStack(that.params['node']); 4884 that.triggerEvent('onRender'); 4885 }; 4886 4887 that.components['action'] = null; 4888 var render = function() { 4889 // Filter search button 4890 cm.addEvent(that.nodes['toolbar']['submit'], 'click', function() { 4891 filterByQuery(); 4892 }); 4893 4894 // Press enter button 4895 cm.addEvent(that.nodes['toolbar']['filter'], 'keypress', function(e) { 4896 if (e.code === 'Enter') { 4897 cm.preventDefault(e); 4898 filterByQuery(); 4899 } 4900 }); 4901 4902 // Filter category select 4903 new cm.Finder('Com.TabsetHelper', null, that.nodes['toolbar']['filter'], function(classObject) { 4904 that.components['category'] = classObject; 4905 that.components['category'].addEvent('onTabShow', function(my) { 4906 filterByCategory(); 4907 }); 4908 }); 4909 4910 // Get Templates List 4911 new cm.Finder('App.TemplateList', that.params['App.TemplateList']['name'], that.nodes['container'], function(classObject) { 4912 that.components['templateList'] = classObject; 4913 }); 4914 }; 4915 4916 var filterByQuery = function() { 4917 var isChanged = false; 4918 if(that.components['category'].get() == 'all') { 4919 isChanged = true; 4920 } 4921 4922 that.components['category'].set('all'); 4923 if(isChanged == true) { 4924 filterByCategory(); 4925 } 4926 }; 4927 4928 var filterByCategory = function() { 4929 var data = cm.getFDO(that.nodes['toolbar']['filter']); 4930 data['category'] = ''; 4931 4932 var category = that.components['category'].get(); 4933 if (category != 'all') { 4934 data['category'] = category; 4935 data['q'] = ''; 4936 4937 var query = that.nodes['toolbar']['filter'].querySelector('input[name="q"]'); 4938 if (query) { 4939 query.value = ''; 4940 } 4941 } 4942 4943 filterAction(data); 4944 }; 4945 4946 var filterAction = function(data) { 4947 if(that.components['templateList']) { 4948 that.components['templateList'].rebuildPagination({ 4949 'ajax' : { 4950 'params' : data 4951 } 4952 }); 4953 } 4954 }; 4955 4956 /* ******* PUBLIC ******* */ 4957 4958 init(); 4959}); 4960 4961cm.define('App.TemplateList', { 4962 'modules' : [ 4963 'Params', 4964 'Events', 4965 'Langs', 4966 'DataConfig', 4967 'DataNodes', 4968 'Stack' 4969 ], 4970 'events' : [ 4971 'onRender', 4972 'onSet', 4973 'onChange', 4974 'onSend' 4975 ], 4976 'params' : { 4977 'node' : cm.Node('div'), 4978 'name' : '', 4979 'type': 'library' // library | signUp 4980 } 4981}, function(params) { 4982 var that = this; 4983 4984 that.components = {}; 4985 that.items = {}; 4986 that.current = null; 4987 that.previous = null; 4988 4989 that.nodes = { 4990 'container' : cm.node('div') 4991 }; 4992 4993 var init = function() { 4994 that.setParams(params); 4995 that.convertEvents(that.params['events']); 4996 that.getDataNodes(that.params['node']); 4997 that.getDataConfig(that.params['node']); 4998 render(); 4999 that.addToStack(that.params['node']); 5000 that.triggerEvent('onRender'); 5001 }; 5002 5003 var render = function() { 5004 new cm.Finder('Com.Pagination', that.params['name'], that.nodes['container'], processPagination); 5005 new cm.Finder('Com.ScrollPagination', that.params['name'], that.nodes['container'], processPagination); 5006 }; 5007 5008 var processPagination = function(classObject) { 5009 if(!that.components['pagination']) { 5010 var pagination = classObject; 5011 pagination.addEvent('onPageRenderEnd', function(my, data) { 5012 new cm.Finder('App.TemplateItem', null, data['container'], processItem); 5013 }); 5014 5015 that.components['pagination'] = pagination; 5016 } 5017 }; 5018 5019 var processItem = function(classObject) { 5020 classObject.addEvent('onCheck', function(my, id) { 5021 if(that.current != id) { 5022 that.previous = that.current; 5023 if(that.previous) { 5024 unCheckItem(that.previous); 5025 } 5026 5027 that.current = id; 5028 that.triggerEvent('onChange', that.current); 5029 } 5030 5031 that.triggerEvent('onSet', that.current); 5032 }); 5033 classObject.addEvent('onSend', function(my, id) { 5034 that.triggerEvent('onSend', that.current); 5035 }); 5036 5037 that.items[classObject.getName()] = classObject; 5038 // Check first finded template if no one was set before 5039 if(!that.current) { 5040 classObject.check(); 5041 } 5042 }; 5043 5044 var unCheckItem = function(id) { 5045 that.items[id].unCheck(); 5046 }; 5047 5048 /* ******* PUBLIC ******* */ 5049 5050 that.rebuildPagination = function(params) { 5051 if(that.components['pagination']) { 5052 var pagination = that.components['pagination']; 5053 pagination.isFinalize = false;
5054 pagination.rebuild(params); 5055 } 5056 5057 return that; 5058 }; 5059 5060 init(); 5061}); 5062 5063cm.define('App.TemplateItem', { 5064 'modules' : [ 5065 'Params', 5066 'Events', 5067 'Langs', 5068 'DataConfig', 5069 'DataNodes', 5070 'Stack' 5071 ], 5072 'events' : [ 5073 'onRender', 5074 'onCheck', 5075 'onUnCheck', 5076 'onSend' 5077 ], 5078 'params' : { 5079 'node' : cm.Node('div'), 5080 'name' : '', 5081 'type': 'library' // library | signUp 5082 } 5083}, function(params) { 5084 var that = this; 5085 5086 that.isCheck = false; 5087 5088 that.nodes = { 5089 'container' : cm.node('div'), 5090 'buttons' : { 5091 'container' : cm.node('div'), 5092 'select' : cm.node('div') 5093 } 5094 }; 5095 5096 var init = function() { 5097 that.setParams(params); 5098 that.convertEvents(that.params['events']); 5099 that.getDataNodes(that.params['node']); 5100 that.getDataConfig(that.params['node']); 5101 render(); 5102 that.addToStack(that.params['node']); 5103 that.triggerEvent('onRender'); 5104 }; 5105 5106 var render = function() { 5107 cm.addEvent(that.nodes['container'], 'click', function(e){ 5108 var target= cm.getEventTarget(e); 5109 if(!cm.isParent(that.nodes['buttons']['container'], target, true)){ 5110 that.check(); 5111 } 5112 }); 5113 5114 cm.addEvent(that.nodes['buttons']['select'], 'click', function (e){ 5115 that.check(e); 5116 that.send(e); 5117 }); 5118 }; 5119 5120 /* ******* PUBLIC ******* */ 5121 5122 that.getName = function(){ 5123 return that.params['name']; 5124 }; 5125 5126 that.check = function() { 5127 if(that.params['type'] === 'signUp' && !that.isCheck) { 5128 that.isCheck = true; 5129 cm.addClass(that.nodes['container'], 'active'); 5130 that.triggerEvent('onCheck', that.params['name']); 5131 } 5132 5133 return that; 5134 }; 5135 5136 that.unCheck = function() { 5137 if(that.params['type'] === 'signUp' && that.isCheck) { 5138 that.isCheck = false; 5139 cm.removeClass(that.nodes['container'], 'active'); 5140 that.triggerEvent('onUnCheck', that.params['name']); 5141 } 5142 5143 return that; 5144 }; 5145 5146 that.send = function(e) { 5147 if(that.params['type'] === 'signUp') { 5148 cm.preventDefault(e); 5149 that.triggerEvent('onSend', that.params['name']); 5150 } 5151 5152 return that; 5153 }; 5154 5155 init(); 5156}); 5157 5158 5159!function () { 5160 // --- Request 5161 Request.add('template-library', function (details, context) { 5162 var nodes = cm.getNodes(context.node); 5163 var parent = nodes['library'].parentNode; 5164 5165 var temp = document.createElement('div'); 5166 temp.innerHTML = details.content; 5167 5168 parent.replaceChild(temp.childNodes[0], nodes['library']); 5169 5170 Collector.construct(parent); 5171 }); 5172 5173 Collector.add('template-library', function (node) { 5174 new App.TemplateLibrary({'node' : node}); 5175 }); 5176 5177 Collector.add('template-list', function (node) { 5178 new App.TemplateList({'node' : node}); 5179 }); 5180 5181 Collector.add('template-item', function (node) { 5182 new App.TemplateItem({'node' : node}); 5183 }); 5184 5185 Collector.add('app_livepreviewmenu', function (node) { 5186 new App.LivePreviewMenu({'node' : node}); 5187 }); 5188 5189 Collector.add('app__livepreviewcontent', function (node) { 5190 new App.LivePreviewContent({'node' : node}); 5191 }); 5192 5193}(); 5194 5195 5196 5197(function () { 5198 Collector.add('undo', function (node) { 5199 5200 var params = node.getAttribute('data-config'); 5201 params = cm.parseJSON(params); 5202 5203 Request.add('block-editor', function (details, context) { 5204 Request.send(params['index-url'], {}, 'get', {}, {'overlay': false}); 5205 }); 5206
5207 Request.add('undo-update', function (details, context) { 5208 var nodes = cm.getNodes(); 5209 if(typeof details['data'] != undefined){ 5210 cm.clearNode(nodes['AppTopMenu']['items']['undo']['actions']); 5211 cm.forEach(details['data'], function(item){ 5212 var container = cm.node('li'); 5213 var href = 'javascript:void();'; 5214 if(item.applied=='No'){ 5215 cm.addClass(container, 'expunge'); 5216 } 5217 if(item.current=='Yes'){ 5218 cm.addClass(container, 'active'); 5219 }else{ 5220 href = unescape(params['apply-url']).replace(/%id%|%25id%25/gi, item.id); 5221 } 5222 cm.appendChild(cm.node('a',{ 5223 'href' : href, 5224 'innerHTML' : item.title, 5225 'data-element' : 'activenew' 5226 }),container); 5227 cm.appendChild(container, nodes['AppTopMenu']['items']['undo']['actions']); 5228 }); 5229 Collector.construct(nodes['AppTopMenu']['items']['undo']['actions']) 5230 } 5231 }); 5232 5233 }); 5234 5235})(); 5236 5237 5238!(function() { 5239 5240 if( typeof CKEDITOR === "undefined" ) { 5241 return; 5242 } 5243 5244 //CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'ckeditor-gwf-plugin' : ',ckeditor-gwf-plugin'; 5245 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'sourcedialog' : ',sourcedialog'; 5246 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'scayt' : ',scayt'; 5247 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'switchbg' : ',switchbg'; 5248 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'oembed' : ',oembed'; 5249 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'balloonpanel' : ',balloonpanel'; 5250 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'a11ychecker' : ',a11ychecker'; 5251 5252 CKEDITOR.config.toolbar_Basic = [ 5253 ['Bold', 'Italic', 'Underline', '-', 'RemoveFormat'], 5254 ['Link', 'Unlink', 'Anchor'], 5255 ['NumberedList','BulletedList','-','Blockquote'] 5256 ]; 5257 5258 CKEDITOR.config.toolbar_Email = [ 5259 ['Bold', 'Italic', 'Underline', '-', 'RemoveFormat'], 5260 ['Link', 'Unlink', 'Anchor'], 5261 ['NumberedList', 'BulletedList', '-', 'Blockquote', 'spoiler', '-', 'Image', 'oembed', 'Source','SwitchBG'], 5262 ['BGColor', 'TextColor'], 5263 ['Scayt'] 5264 ]; 5265 5266 Collector.add('richEditor', 5267 function(node) { 5268 var options = { 5269 removePlugins : 'preview' 5270 }; 5271 var params = node.getAttribute('data-config'); 5272 params = cm.parseJSON(params); 5273 if (params) { 5274 options = cm.merge(options, params); 5275 } 5276 var editor = CKEDITOR.replace(node, options); 5277 node.setAttribute('data-editor', editor.name); 5278 }, 5279 function(node) { 5280 var editor = CKEDITOR.instances[node.getAttribute('data-editor')]; 5281 if (editor) { 5282 editor.updateElement(); 5283 } 5284 } 5285 ); 5286 5287 Collector.add('bbcodeEditor', 5288 function(node) { 5289 var options = { 5290 extraPlugins: CKEDITOR.config.extraPlugins + ',bbcode', 5291 removePlugins: 5292 'bidi,dialogadvtab,div,filebrowser,flash,format,forms,horizontalrule,iframe,justify,liststyle,pagebreak,showborders,stylescombo,table,tabletools,templates' 5293 5294 }; 5295 var params = node.getAttribute('data-config'); 5296 params = cm.parseJSON(params); 5297 if (params) { 5298 options = cm.merge(options, params); 5299 } 5300 var editor = CKEDITOR.replace(node, options); 5301 node.setAttribute('data-editor', editor.name); 5302 }, 5303 function(node) { 5304 var editor = CKEDITOR.instances[node.getAttribute('data-editor')]; 5305 if (editor) { 5306 editor.updateElement(); 5307 } 5308 } 5309 ); 5310 5311 // Fix for Lightbox and HelpBox maximize issue 5312 CKEDITOR.on('instanceCreated', function(evt) { 5313 evt.editor.on('afterCommandExec',function(e){ 5314 var state = 0; 5315 if(e.data.name === 'maximize' && 0 === state){ 5316 state = 1; 5317 $('div.cke_inner.cke_reset.cke_maximized').css('z-index', 1005); 5318 } 5319 //Firefox fix 5320 if(e.data.name === 'maximize' && 1 === state){ 5321 state = 0; 5322 $('body').attr('contenteditable','false'); 5323 } 5324 }); 5325 5326 var changeFlag = false;
5327 evt.editor.on('change', function(e){ 5328 5329 if (changeFlag) clearTimeout(changeFlag); 5330 changeFlag = setTimeout(function(){ 5331 var value = evt.editor.getData(); 5332 var name = evt.editor.name; 5333 5334 var el = cm.getEl(name); 5335 if (el){ 5336 el.value = value; 5337 } 5338 }, parseInt(500)); 5339 }); 5340 }); 5341 5342 //fix image size 5343 CKEDITOR.on('instanceReady', function (ev) { 5344 ev.editor.dataProcessor.htmlFilter.addRules( { 5345 elements: { 5346 img: function( el ) { 5347 if(!el.attributes['style'] ){ 5348 el.attributes['style'] = 'height: auto; width: auto; max-width:100%;'; 5349 } 5350 } 5351 } 5352 }); 5353 }); 5354 5355})(); 5356 5357 5358 5359 5360cm.define('App.ModuleBlogSlider', { 5361 'modules' : [ 5362 'Params', 5363 'Events', 5364 'Langs', 5365 'DataConfig', 5366 'DataNodes', 5367 'Stack' 5368 ], 5369 'events' : [ 5370 'onRender', 5371 'onEnableEditing', 5372 'onEnableEditable', 5373 'onDisableEditing', 5374 'onDisableEditable' 5375 ], 5376 'params' : { 5377 'node' : cm.node('div'), 5378 'name' : '', 5379 'isEditing' : false, 5380 'customEvents' : true 5381 } 5382 }, 5383 function(params){ 5384 var that = this; 5385 5386 that.nodes = { 5387 'buttons' : { 5388 'edit' : cm.node('div'), 5389 'delete' : cm.node('div'), 5390 'prev' : cm.node('div'), 5391 'next' : cm.node('div') 5392 } 5393 }; 5394 that.components = {}; 5395 that.isEditing = null; 5396 5397 var init = function(){ 5398 that.setParams(params); 5399 that.convertEvents(that.params['events']); 5400 that.getDataNodes(that.params['node']); 5401 that.getDataConfig(that.params['node']); 5402 that.addToStack(that.params['node']); 5403 render(); 5404 5405 that.triggerEvent('onRender'); 5406 }; 5407 5408 var render = function(){ 5409 that.nodes['buttons']['prev'].style.display = 'none'; 5410 that.nodes['buttons']['next'].style.display = 'none'; 5411 that.nodes['buttons']['edit'].style.display = 'none'; 5412 that.nodes['buttons']['delete'].style.display = 'none'; 5413 5414 new cm.Finder('Com.Slider', that.params['name'], that.nodes['container'], function (classObject) { 5415 that.components['slider'] = classObject; 5416 process(); 5417 }); 5418 5419 }; 5420 5421 var process = function(){ 5422 that.nodes['buttons']['prev'].style.display = ''; 5423 that.nodes['buttons']['next'].style.display = ''; 5424 that.nodes['buttons']['edit'].style.display = ''; 5425 that.nodes['buttons']['delete'].style.display = ''; 5426 5427 var current; 5428 if(current = that.components['slider'].get(that.components['slider'].current)){ 5429 bindControls(that.components['slider'], {'current' : current}); 5430 } 5431 // Add events 5432 cm.addEvent(that.nodes['buttons']['prev'], 'click', that.components['slider'].prev); 5433 cm.addEvent(that.nodes['buttons']['next'], 'click', that.components['slider'].next); 5434 that.components['slider'].addEvent('onChange', bindControls); 5435 // Add custom event 5436 if(that.params['customEvents']){ 5437 cm.customEvent.add(that.params['node'], 'enableEditable', function(){ 5438 that.enableEditing(); 5439 }); 5440 cm.customEvent.add(that.params['node'], 'disableEditable', function(){ 5441 that.disableEditing(); 5442 }); 5443 } 5444 // Editing 5445 that.params['isEditing'] && that.enableEditing(); 5446 }; 5447 5448 var bindControls = function(slider, data){ 5449 var id = data.current['nodes']['container'].getAttribute('data-id'); 5450 // Bind buttons 5451 that.nodes['buttons']['edit'].setAttribute('href', that.nodes['buttons']['edit'].getAttribute('data-base-url')+ '/' + id); 5452 that.nodes['buttons']['delete'].setAttribute('href', that.nodes['buttons']['delete'].getAttribute('data-base-url')+ '/' + id); 5453 }; 5454 5455 /* ******* MAIN ******* */ 5456 5457 that.enableEditing = function(){ 5458 if(!cm.isBoolean(that.isEditing) || !that.isEditing){ 5459 that.isEditing = true; 5460 cm.addClass(that.params['node'], 'is-editing is-editable'); 5461 that.triggerEvent('onEnableEditing'); 5462 that.triggerEvent('onEnableEditable'); 5463 } 5464 return that; 5465 }; 5466 5467 that.disableEditing = function(){ 5468 if(!cm.isBoolean(that.isEditing) || that.isEditing){ 5469 that.isEditing = false;
5470 cm.removeClass(that.params['node'], 'is-editing is-editable'); 5471 that.triggerEvent('onDisableEditing'); 5472 that.triggerEvent('onDisableEditable'); 5473 } 5474 return that; 5475 }; 5476 5477 init(); 5478 }); 5479 5480(function () { 5481 5482 Collector.add('module_blog_archive', function (node) { 5483 new cm.Finder('Com.Select', 'archive', node, function (classObject) { 5484 classObject.addEvent('onChange', function (element, value) { 5485 if (value) { 5486 window.location = value; 5487 } 5488 }) 5489 }) 5490 }) 5491 5492 Collector.add('module_blog_slider', function (node) { 5493 new App.ModuleBlogSlider({'node' : node}); 5494 }); 5495 5496 Collector.add('blog_slider', function (node) { 5497 new Com.Slider({'node': node}); 5498 }); 5499 5500 Collector.add('select', function(node) { 5501 if (node.name === 'general[blogId]') { 5502 var blogId = Com.GetSelect('general[blogId]'); 5503 if (blogId) { 5504 blogId.addEvent('onSelect', function(select, active) { 5505 Request.send(node.getAttribute('data-url'), {'id': active}, 'post', {}, {'overlay': false}); 5506 }); 5507 //blogId.set(blogId.get(), true); 5508 } 5509 } 5510 }); 5511 5512 Request.add('blog-categories-select', function(details, context) { 5513 var categories = Com.GetSelect('general[categories][]'); 5514 if (categories) { 5515 var options = categories.getOptionsAll(); 5516 var empty = null; 5517 cm.forEach(options, function(option){ 5518 if(option.value==''){ 5519 empty = option; 5520 } 5521 }); 5522 categories.removeOptionsAll(); 5523 categories.addOptions(details['categories']); 5524 if(empty){ 5525 categories.addOption(empty.value, empty.text); 5526 categories.set(empty.value); 5527 } 5528 } 5529 var category = Com.GetSelect('general[category]'); 5530 if (category) { 5531 var options = category.getOptionsAll(); 5532 var empty = null; 5533 cm.forEach(options, function(option){ 5534 if(option.value==''){ 5535 empty = option; 5536 } 5537 }); 5538 category.removeOptionsAll(); 5539 category.addOptions(details['categories']); 5540 if(empty){ 5541 5542 category.addOption(empty.value, empty.text); 5543 category.set(empty.value); 5544 } 5545 } 5546 }); 5547 5548})(); 5549 5550 5551 5552!function() { 5553 if( typeof CKEDITOR !== "undefined" ) { 5554 CKEDITOR.config.toolbar_Comment = [ 5555 ['Bold', 'Italic', 'Underline', '-', 'RemoveFormat'], 5556 ['Link', 'Unlink', 'Anchor'], 5557 ['NumberedList', 'BulletedList', '-', 'Blockquote'], 5558 ['Scayt'] 5559 ]; 5560 } 5561 5562 Collector.add('comment-create', function(node) { 5563 var comment = cm.getNodes(node); 5564 cm.addEvent(comment['commentForm'], 'submit', function(e) { 5565 Collector.destruct(node); 5566 Request.send(comment['commentForm'].getAttribute('action'), 5567 cm.getFDO(comment['commentForm']), 'post', {'node': node}); 5568 cm.preventDefault(e); 5569 }); 5570 if ('commentReplyClose' in comment) { 5571 cm.addEvent(comment['commentReplyClose'], 'click', function(e) { 5572 var nodes = cm.getNodes(node); 5573 if (nodes['oldBody']) { 5574 nodes['oldBody'].setAttribute('data-node', 'body'); 5575 nodes['oldBody'].setAttribute('style', ''); 5576 cm.insertBefore(nodes['oldBody'], node); 5577 Collector.construct(nodes['oldBody']); 5578 } 5579 Collector.destruct(node); 5580 cm.remove(node); 5581 cm.preventDefault(e); 5582 }); 5583 } 5584 }); 5585 Collector.add('comment', function(node) { 5586 setTimeout(function(){ 5587 var comment = cm.getNodes(node); 5588 cm.forEach(comment['children'][0]['buttons'], function(button) { 5589 cm.addEvent(button, 'click', function(e) { 5590 Request.send(button.getAttribute('data-url'), {}, 'get', {'node': comment['children'][0]}); 5591 cm.preventDefault(e); 5592 }); 5593 }); 5594 },20); 5595 }); 5596 5597 Collector.add('comment-list', function (node){ 5598 cm.addEvent(node, 'click', function(e) { 5599 Request.send(node.getAttribute('data-url'), {}, 'get', {}, {'overlay': true}); 5600 cm.preventDefault(e); 5601 }); 5602 }); 5603 5604// Collector.add('comments', function(node) { 5605// var addAction = function(list){ 5606// if(list['children']){ 5607// cm.forEach(list['children'], function(item) { 5608// cm.forEach(item['buttons'], function(button) { 5609// cm.addEvent(button, 'click', function(e) { 5610// Request.send(button.getAttribute('data-url'), {}, 'get', {'node': item}); 5611// cm.preventDefault(e); 5612// }); 5613// }); 5614// addAction(item); 5615// }); 5616// } 5617// } 5618// addAction(cm.getNodes(node)); 5619// }); 5620 Request.add('admin-comments', function(details, context) { 5621 if (context && context['dialog']) { 5622 context['dialog'].close(); 5623 } 5624 new Com.Overlay(); 5625 window.location.reload(); 5626 }); 5627 Request.add('comments', function(details, context) { 5628 switch (details['name']) { 5629 case 'create': 5630 if (details['form']) { 5631 //append new form 5632 var content = cm.strToHTML(details['form']); 5633 cm.insertAfter(content, context['node']); 5634 Collector.construct(content); 5635 //remove old create form 5636 cm.remove(context['node']); 5637 } 5638 if (details['content']) { 5639 //append new comment block 5640 var comments = cm.getByAttr('data-instance-id',context['node'].getAttribute('data-id')); 5641 cm.forEach(comments, function(comment) { 5642 var nodes = cm.getNodes(comment); 5643 var content = cm.strToHTML(details['content']); 5644 cm.appendNodes(content, nodes['Comments'][0]['child']); 5645 Collector.construct(content); 5646 if (nodes['Comments'][0]['children'] && nodes['Comments'][0]['children'][0]['noItems']) { 5647 nodes['Comments'][0]['children'][0]['noItems'].setAttribute('style', 'display:none;'); 5648 } 5649 }); 5650 } 5651 break; 5652 case 'reply': 5653 if (details['form']) { 5654 if (context['node']['child']) { 5655 //insert new reply form 5656 var content = cm.strToHTML(details['form']); 5657 cm.insertFirst(content, context['node']['child']); 5658 Collector.construct(content); 5659 } else { 5660 var comments = cm.getByAttr('data-id', context['node'].getAttribute('data-parent-id')); 5661 cm.forEach(comments, function(comment) { 5662 var nodes = cm.getNodes(comment); 5663 //remove old reply form 5664 cm.remove(cm.firstEl(nodes['children'][0]['child'])); 5665 //insert new reply form 5666 var content = cm.strToHTML(details['form']); 5667 cm.appendChild(content, nodes['children'][0]['child']); 5668 Collector.construct(content); 5669 }); 5670 } 5671 } 5672 if (details['content']) { 5673 var comments = cm.getByAttr('data-id', context['node'].getAttribute('data-parent-id')); 5674 cm.forEach(comments, function(comment) { 5675 var nodes = cm.getNodes(comment); 5676 var content = cm.strToHTML(details['content']); 5677 cm.appendChild(content, nodes['children'][0]['child']); 5678 Collector.construct(content); 5679 }); 5680 cm.remove(context['node']); 5681 5682 } 5683 break; 5684 case 'modify': 5685 if (details['form']) { 5686 var content = cm.strToHTML(details['form']); 5687 if (context['node']['body']) { 5688 //insert new form 5689 cm.insertFirst(content, context['node']['comment']); 5690 Collector.construct(content); 5691 //hide and append old form for cancel action 5692 context['node']['body'].setAttribute('data-node', 'oldBody'); 5693 context['node']['body'].setAttribute('style', 'display:none;'); 5694 cm.appendChild(context['node']['body'], content); 5695 } else { 5696 var nodes = cm.getNodes(context['node']); 5697 cm.insertBefore(content, nodes['body']); 5698 Collector.construct(content); 5699 //move old comment body for cancel action
5700 cm.appendChild(nodes['oldBody'], content); 5701 //remove previous form 5702 cm.remove(nodes['body']); 5703 5704 } 5705 } 5706 if (details['content']) { 5707 var comments = cm.getByAttr('data-id', context['node'].getAttribute('data-modify-id')); 5708 cm.forEach(comments, function(comment) { 5709 var nodes = cm.getNodes(comment); 5710 var content = cm.strToHTML(details['content']); 5711 cm.insertBefore(content, nodes['children'][0]['comment']); 5712 Collector.construct(content); 5713 cm.remove(nodes['children'][0]['comment']); 5714 }); 5715 } 5716 break; 5717 case 'approve': 5718 case 'expunge': 5719 case 'update': 5720 if (details['content']) { 5721 var content = cm.strToHTML(details['content']); 5722 cm.insertAfter(content, context['node']['comment']); 5723 Collector.construct(content); 5724 cm.remove(context['node']['comment']); 5725 } 5726 if (details['name'] == 'update') { 5727 context['dialog'].close(); 5728 } 5729 break; 5730 case 'delete': 5731 cm.remove(context['node']['comment']); 5732 var nodes = cm.getNodes(); 5733 cm.forEach(nodes['Comments'], function(comment) { 5734 if (comment['children'].length == 1) { 5735 comment['children'][0]['noItems'].removeAttribute('style'); 5736 } 5737 }); 5738 //context['dialog'].close(); 5739 break; 5740 } 5741 }); 5742 5743}(); 5744 5745 5746 5747cm.define('App.FormEvent', { 5748 'modules': [ 5749 'Params', 5750 'Events', 5751 'Langs', 5752 'DataConfig', 5753 'DataNodes', 5754 ], 5755 'events': [ 5756 'onRender' 5757 ], 5758 'params': { 5759 'node': cm.Node('div'), 5760 'name': '' 5761 } 5762}, 5763 function (params) { 5764 var that = this; 5765 5766 var init = function () { 5767 that.setParams(params); 5768 that.convertEvents(that.params['events']); 5769 that.getDataNodes(that.params['node']); 5770 that.getDataConfig(that.params['node']); 5771 render(); 5772 that.triggerEvent('onRender'); 5773 }; 5774 5775 var render = function () { 5776 /* metaTitle */ 5777 var metaTitle = function () { 5778 var count = that.nodes['metaTitle'].getAttribute('data-maxLength') - that.nodes['metaTitle'].value.length; 5779 var hintText = that.nodes['metaTitleHint'].getAttribute('data-text'); 5780 var hint = (count < 0) ? '<span style="color:red">' + count + ' ' + hintText + '</span>' : count + ' ' + hintText; 5781 that.nodes['metaTitleHint'].innerHTML = hint; 5782 }; 5783 cm.addEvent(that.nodes['metaTitle'], 'input', metaTitle); 5784 metaTitle(); 5785 5786 /* metaKeywords */ 5787 var metaKeywords = function () { 5788 var count = that.nodes['metaKeywords'].getAttribute('data-maxLength') - that.nodes['metaKeywords'].value.length; 5789 var hintText = that.nodes['metaKeywordsHint'].getAttribute('data-text'); 5790 var hint = (count < 0) ? '<span style="color:red">' + count + ' ' + hintText + '</span>' : count + ' ' + hintText; 5791 that.nodes['metaKeywordsHint'].innerHTML = hint; 5792 }; 5793 cm.addEvent(that.nodes['metaKeywords'], 'input', metaKeywords); 5794 metaKeywords(); 5795 5796 /* metaDescr */ 5797 var metaDescr = function () { 5798 var count = that.nodes['metaDescr'].getAttribute('data-maxLength') - that.nodes['metaDescr'].value.length; 5799 var hintText = that.nodes['metaDescrHint'].getAttribute('data-text'); 5800 var hint = (count < 0) ? '<span style="color:red">' + count + ' ' + hintText + '</span>' : count + ' ' + hintText; 5801 that.nodes['metaDescrHint'].innerHTML = hint; 5802 }; 5803 cm.addEvent(that.nodes['metaDescr'], 'input', metaDescr); 5804 metaDescr(); 5805 5806 /* alldayCheckbox */ 5807 var alldayCheckbox = function () { 5808 var form = cm.getParentByTagName('form', that.nodes['alldayCheckbox']); 5809 var el = cm.getByName('publishedtime', form)[0]; 5810 var el2 = cm.getByName('completedtime', form)[0]; 5811 5812 var dl = cm.getParentByTagName('dl', el); 5813 var dl2 = cm.getParentByTagName('dl', el2); 5814 5815 if (that.nodes['alldayCheckbox'].checked) { 5816 cm.addClass(dl, 'display-none'); 5817 cm.addClass(dl2, 'display-none'); 5818 } else { 5819 cm.removeClass(dl, 'display-none'); 5820 cm.removeClass(dl2, 'display-none'); 5821 } 5822 }; 5823 cm.addEvent(that.nodes['alldayCheckbox'], 'change', alldayCheckbox); 5824 alldayCheckbox(); 5825 5826 }; 5827 5828 /* ******* MAIN ******* */ 5829 5830 init(); 5831 5832 }); 5833 5834!function ($) { 5835 Collector.add('htmlpreview', function (node) { 5836 5837 var preview = cm.getEl('html_preview'), 5838 appendText = cm.getEl('add_text_to_email'), 5839 startTime = 0, 5840 template = preview.value, 5841 el = document.createElement('div'); 5842 5843 preview.parentNode.appendChild(el); 5844 preview.style.display = 'none'; 5845 el.innerHTML = template; 5846 var changeTemplate = function (endTime, temp) { 5847 if (startTime && ((endTime - startTime) > 300)) 5848 { 5849 setTimeout(function () { 5850 el.innerHTML = template; 5851 el.innerHTML = el.innerHTML + appendText.value; 5852 }, 1000); 5853 startTime = endTime; 5854 } else if (!startTime) 5855 { 5856 startTime = new Date().getTime(); 5857 } 5858 } 5859 appendText.addEventListener('keyup', function () { 5860 changeTemplate(new Date().getTime(), appendText.value) 5861 }, true); 5862 }); 5863 5864 Collector.add('events-select', function (node) { 5865 var attendees = Com.GetSelect('attendees[]').getOptionsAll(); 5866 var arr = Com.GetSelect('attendees[]').get(0); 5867 5868 for (var option in attendees) { 5869 if (-1 != jQuery.inArray(attendees[option].value, arr)) { 5870 $('[name="emailAttendees[]"]').append('<option value="' + attendees[option].value + '">' + attendees[option].text + '</option>'); 5871 } 5872 } 5873 }); 5874 5875 Collector.add('select', function (node) { 5876 if (node.name === 'general[events]') { 5877 var event = Com.GetSelect('general[events]'); 5878 if (event) { 5879 event.addEvent('onSelect', function (select, active) { 5880 Request.send(node.getAttribute('data-url'), {'id': active}, 'post', {}, {'overlay': true}); 5881 }); 5882 } 5883 } else if (node.id === 'eventRepeatParam') { 5884 var type = Com.GetSelect('eventRepeatParam'); 5885 var form = cm.getParentByTagName('form', type.getNodes()['hidden']); 5886 var weeklyElement = cm.getByAttr('data-element', 'repeatweeklydl', form); 5887 weeklyElement = weeklyElement[0]; 5888 5889 var el = cm.getByName('completed', form)[0]; 5890 var dl = cm.getParentByTagName('dl', el); 5891 5892 var el1 = cm.getByName('until', form)[0]; 5893 var dl1 = cm.getParentByTagName('dl', el1); 5894 5895 var hideWeekly = function () { 5896 if ('weekly' == type.get()) { 5897 // show dl 5898 cm.removeClass(weeklyElement, 'display-none'); 5899 } else { 5900 // hide dl 5901 cm.addClass(weeklyElement, 'display-none'); 5902 } 5903 5904 if ('never' == type.get()) { 5905 // show dl 5906 cm.removeClass(dl, 'display-none'); 5907 cm.addClass(dl1, 'display-none'); 5908 } else { 5909 // hide dl 5910 cm.addClass(dl, 'display-none'); 5911 cm.removeClass(dl1, 'display-none'); 5912 } 5913 } 5914 if (type) { 5915 type.addEvent('onSelect', function () { 5916 hideWeekly(); 5917 }); 5918 hideWeekly(); 5919 } 5920 } else if (node.id === 'eventPublishingStatus') { 5921// var status = Com.GetSelect('eventPublishingStatus'); 5922// var form = cm.getParentByTagName('form', status.getNodes()['hidden']); 5923// 5924// var element = cm.getByName('startpublishing', form)[0]; 5925// var dl1 = cm.getParentByTagName('dl', element); 5926// var element = cm.getByName('stoppublishing', form)[0]; 5927// var dl2 = cm.getParentByTagName('dl', element); 5928// var hidePeriod = function () { 5929// if ('always' == status.get()) { 5930// // hide dl 5931// cm.addClass(dl1, 'display-none'); 5932// cm.addClass(dl2, 'display-none'); 5933// } else { 5934// // show dl 5935// cm.removeClass(dl1, 'display-none'); 5936// cm.removeClass(dl2, 'display-none'); 5937// } 5938// } 5939// if (status) { 5940// status.addEvent('onSelect', function () { 5941// hidePeriod(); 5942// }); 5943// hidePeriod(); 5944// } 5945 } 5946 5947 }); 5948 5949 Request.add('events-categories-select', function (details, context) { 5950 var categories = Com.GetSelect('general[categories][]'); 5951 if (categories) { 5952 var options = categories.getOptionsAll(); 5953 var empty = null;
5954 cm.forEach(details['categories'], function (option) { 5955 if (option.value == '') { 5956 empty = option; 5957 } 5958 }); 5959 categories.removeOptionsAll(); 5960 categories.addOptions(details['categories']); 5961 if (empty) { 5962 categories.addOption(empty.value, empty.text); 5963 //categories.set(empty.value); 5964 } else { 5965 categories.set(context.params); 5966 } 5967 } 5968 var category = Com.GetSelect('general[category][]'); 5969 if (category) { 5970 var options = category.getOptionsAll(); 5971 var empty = null; 5972 cm.forEach(options, function (option) { 5973 if (option.value == '') { 5974 empty = option; 5975 } 5976 }); 5977 category.removeOptionsAll(); 5978 category.addOptions(details['categories']); 5979 if (empty) { 5980 5981 category.addOption(empty.value, empty.text); 5982 category.set(empty.value); 5983 } 5984 } 5985 }); 5986 5987 Collector.add('form_event', function (node) { 5988 new App.FormEvent({'node': node}); 5989 }); 5990 5991 Collector.add('events-big_calendar_event', function (node) { 5992 new Module.CalendarEvent({ 5993 'node': node 5994 }); 5995 }); 5996 5997 Collector.add('events-big_calendar', function (node) { 5998 new Module.Calendar({ 5999 'node': node, 6000 'events': { 6001 'onProcessEnd': function (calendar, node) { 6002 window.Collector.construct(node); 6003 } 6004 }, 6005 'defaultView': 'month' 6006 }); 6007 }); 6008 6009 Collector.add('events-big_calendar_agenda', function (node) { 6010 new Module.CalendarAgenda({ 6011 'node': node 6012 }); 6013 }); 6014 6015 Collector.add('events-big_calendar_week', function (node) { 6016 new Module.CalendarWeek({ 6017 'node': node 6018 }); 6019 }); 6020 6021 Collector.add('events-big_calendar_month', function (node) { 6022 new Module.CalendarMonth({ 6023 'node': node 6024 }); 6025 }); 6026 6027 Collector.add('events-filter', function (node) { 6028 cm.addEvent(node, 'change', function (e) { 6029 var form = cm.getParentByTagName('form', node); 6030 new cm.Finder('Module.Calendar', form.getAttribute('data-calendar'), null, function (classObject) { 6031 var request = { 6032 'params': {} 6033 }; 6034 var data = cm.getFDO(form); 6035 request.params.categories = data.categories || 0; 6036 classObject 6037 .setAction(request, 'update') 6038 .refresh(); 6039 6040 }, {'multiple': true}); 6041 }); 6042 }); 6043 6044 Collector.add('events-categories_block_form_events', function (node) { 6045 new cm.Finder('Com.Select', 'general[eventId]', node, function (classObject) { 6046 var instanse = classObject; 6047 var parent = cm.getParentByTagName('li', node); 6048 6049 instanse.addEvent('onChange', function (element, value) { 6050 new cm.Finder('Com.Select', 'general[categories][]', parent, function (classObject) { 6051 if (value){ 6052 Request.send(node.getAttribute('data-url'), {'id': value}, 'post', {'params': classObject.get()}, {'overlay': false}); 6053 } 6054 }); 6055 }); 6056 6057 instanse.triggerEvent('onChange', instanse.get()); 6058 }) 6059 }); 6060 6061}(window.jQuery); 6062 6063 6064!function ($) { 6065 6066}(window.jQuery); 6067 6068 6069 6070!function () { 6071 Collector.add('App.FormBlock.FileGridList', function (node) { 6072 var nodes = cm.getNodes(node); 6073 var filegridlistcategory = nodes['App']['FormBlock']['FileGridList']['filegridlistcategory']; 6074 new cm.Finder('Com.Select', 'general[filegridlistId]', node, function (filegridlist) { 6075 filegridlist.addEvent('onChange', function (element, value) { 6076 cm.addClass(filegridlistcategory,'display-none'); 6077 if (value) { 6078 cm.ajax({ 6079 'type': 'text', 6080 'method': 'GET', 6081 'params': {'id': value}, 6082 'url': filegridlist['params']['node'].getAttribute('data-url'), 6083 'onSuccess': function (response, load) { 6084 var result = cm.parseJSON(response); 6085 if (result && result.result) { 6086 new cm.Finder('Com.Select', 'general[filegridlistcategory][]', node, function (category) { 6087 category.removeOptionsAll(); 6088 var details = result.details.categories; 6089 if (details) {
6090 cm.forEach(details, function (label, value) { 6091 category.addOption(value, label); 6092 }); 6093 } 6094 }); 6095 } 6096 cm.removeClass(filegridlistcategory,'display-none'); 6097 } 6098 }); 6099 } 6100 }); 6101 filegridlist.triggerEvent('onChange', filegridlist.get()); 6102 }); 6103 }); 6104}(); 6105 6106 6107 6108cm.define('App.FormForum', { 6109 'modules': [ 6110 'Params', 6111 'Events', 6112 'Langs', 6113 'DataConfig', 6114 'DataNodes' 6115 ], 6116 'events': [ 6117 'onRender' 6118 ], 6119 'params': { 6120 'node': cm.Node('div'), 6121 'name': '' 6122 } 6123}, 6124 function (params) { 6125 var that = this; 6126 that.components = {}; 6127 var init = function () { 6128 that.setParams(params); 6129 that.convertEvents(that.params['events']); 6130 that.getDataNodes(that.params['node']); 6131 that.getDataConfig(that.params['node']); 6132 render(); 6133 that.triggerEvent('onRender'); 6134 }; 6135 6136 var render = function () { 6137 /* metaTitle */ 6138 var metaTitle = function () { 6139 var count = that.nodes['metaTitle'].getAttribute('data-maxLength') - that.nodes['metaTitle'].value.length; 6140 var hintText = that.nodes['metaTitleHint'].getAttribute('data-text'); 6141 var hint = (count < 0) ? '<span style="color:red">' + count + ' ' + hintText + '</span>' : count + ' ' + hintText; 6142 that.nodes['metaTitleHint'].innerHTML = hint; 6143 }; 6144 cm.addEvent(that.nodes['metaTitle'], 'input', metaTitle); 6145 metaTitle(); 6146 6147 /* metaKeywords */ 6148 var metaKeywords = function () { 6149 var count = that.nodes['metaKeywords'].getAttribute('data-maxLength') - that.nodes['metaKeywords'].value.length; 6150 var hintText = that.nodes['metaKeywordsHint'].getAttribute('data-text'); 6151 var hint = (count < 0) ? '<span style="color:red">' + count + ' ' + hintText + '</span>' : count + ' ' + hintText; 6152 that.nodes['metaKeywordsHint'].innerHTML = hint; 6153 }; 6154 cm.addEvent(that.nodes['metaKeywords'], 'input', metaKeywords); 6155 metaKeywords(); 6156 6157 /* metaDescr */ 6158 var metaDescr = function () { 6159 var count = that.nodes['metaDescr'].getAttribute('data-maxLength') - that.nodes['metaDescr'].value.length; 6160 var hintText = that.nodes['metaDescrHint'].getAttribute('data-text'); 6161 var hint = (count < 0) ? '<span style="color:red">' + count + ' ' + hintText + '</span>' : count + ' ' + hintText; 6162 that.nodes['metaDescrHint'].innerHTML = hint; 6163 }; 6164 cm.addEvent(that.nodes['metaDescr'], 'input', metaDescr); 6165 metaDescr(); 6166 6167 /* publishingstatus */ 6168 var publishingstatus = function (element, value) { 6169 if ('always' == value) { 6170 cm.addClass(that.nodes['startpublishing'], 'display-none'); 6171 cm.addClass(that.nodes['stoppublishing'], 'display-none'); 6172 } else { 6173 cm.removeClass(that.nodes['startpublishing'], 'display-none'); 6174 cm.removeClass(that.nodes['stoppublishing'], 'display-none'); 6175 } 6176 } 6177 new cm.Finder('Com.Select', 'publishingstatus', that.params['node'], function (classObject) { 6178 that.components['publishingstatus'] = classObject; 6179 that.components['publishingstatus'].addEvent('onChange', publishingstatus); 6180 publishingstatus(that.components['publishingstatus'], that.components['publishingstatus'].get()); 6181 }); 6182 }; 6183 6184 6185 /* ******* MAIN ******* */ 6186 init(); 6187 }); 6188 6189!function () { 6190 if( typeof CKEDITOR !== "undefined" ) { 6191 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'spoiler' : ',spoiler'; 6192 CKEDITOR.config.toolbar_Forum = [ 6193 ['Bold', 'Italic', 'Underline', '-', 'RemoveFormat'], 6194 ['Link', 'Unlink', 'Anchor'], 6195 ['NumberedList', 'BulletedList', '-', 'Blockquote', 'spoiler', '-', 'Image', 'oembed', 'Source'], 6196 ['BGColor', 'TextColor'] 6197 ]; 6198 } 6199 6200 Collector.add('form_forum_category', function (node) { 6201 new App.FormForum({'node': node, 'nodesMarker': 'AppFormCategoryForm'}); 6202 }); 6203 Collector.add('form_forum_topic', function (node) { 6204 new App.FormForum({'node': node, 'nodesMarker': 'AppFormTopicForm'}); 6205 }); 6206 Collector.add('form_forum_widget', function (node) { 6207 new cm.Finder('Com.Select', 'general[forum]', node, function (forum) { 6208 forum.addEvent('onChange', function () { 6209 var nodes = forum.getNodes(); 6210 var hiddenSelect = nodes['hidden'];
6211 var overlay = new Com.Overlay(); 6212 cm.ajax({ 6213 'type': 'text', 6214 'method': 'GET', 6215 'params': {'forum': forum.get()}, 6216 'url': hiddenSelect.getAttribute('data-link'), 6217 'onSuccess': function (response, load) { 6218 //close overlay 6219 if (overlay) { 6220 setTimeout(function () { 6221 overlay.close(); 6222 }, 100); 6223 } 6224 new cm.Finder('Com.Select', 'general[category][]', node, function (category) { 6225 category.removeOptionsAll(); 6226 if (!load || load.target.status != 200) { 6227 return false; 6228 } 6229 var result = cm.parseJSON(response); 6230 if (result && result.result) { 6231 var details = result.details.categories; 6232 if (details) { 6233 cm.forEach(details, function (label, value) { 6234 if (cm.isObject(label)){ 6235 label = label.label; 6236 } 6237 category.addOption(value, label); 6238 }); 6239 } 6240 } 6241 }); 6242 } 6243 }); 6244 }); 6245 }); 6246 }); 6247 6248 6249 Collector.add('noaccess', function (node) { 6250 cm.addEvent(node, 'click', function (e) { 6251 var backTo = window.location.href; 6252 var toLogin = '/user/login?back=' + backTo; 6253 var toRegist = '/user/registration?back=' + backTo; 6254 new Com.Dialog({ 6255 title: 'No access', 6256 zIndex: 9999, 6257 closeBtn: true, 6258 content: cm.Node("div", { 6259 innerHTML: unescape('Please <a href="' + toLogin + '">login</a> or <a href="' + toRegist + '">register</a> to send reply.') 6260 }) 6261 }).open(); 6262 6263 cm.preventDefault(e); 6264 }); 6265 }); 6266}(); 6267 6268 6269 6270 6271!function() { 6272 Collector.add('glossary', function(node){ 6273 new Com.Glossary({'node' : node}) 6274 }, function(node) { 6275 var items = cm.getByClass('com__glossary__title', node); 6276 cm.forEach(items, function(item) { 6277 cm.insertAfter(document.createTextNode(item.textContent), node); 6278 }); 6279 cm.remove(node); 6280 }); 6281 6282}(); 6283 6284 6285 6286cm.define('App.ModuleGoogleMap', { 6287 'extend' : 'Com.AbstractController', 6288 'params' : { 6289 'renderStructure' : false, 6290 'embedStructureOnRender' : false, 6291 'customEvents' : true, 6292 'resizeEvent' : true, 6293 'zoom' : 11, 6294 'url' : null 6295 } 6296}, 6297function(params){ 6298 var that = this; 6299 // Call parent class construct 6300 Com.AbstractController.apply(that, arguments); 6301}); 6302 6303cm.getConstructor('App.ModuleGoogleMap', function(classConstructor, className, classProto){ 6304 var _inherit = classProto._inherit; 6305 6306 classProto.construct = function() { 6307 var that = this; 6308 that.onRedrawHandler = that.onRedraw.bind(that); 6309 // Bind Events 6310 that.addEvent('onRedraw', that.onRedrawHandler); 6311 // Call parent method - construct 6312 _inherit.prototype.construct.apply(that, arguments); 6313 }; 6314 6315 classProto.renderViewModel = function(){ 6316 var that = this; 6317 // Call parent method - renderViewModel 6318 _inherit.prototype.renderViewModel.apply(that, arguments); 6319 // Process map 6320 that.processMap(); 6321 return that; 6322 }; 6323 6324 classProto.processMap = function(){ 6325 var that = this; 6326 // Get Config 6327 var styles = atob(that.params['node'].getAttribute('data-google-style')); 6328 var address = that.params['node'].getAttribute('data-google-address'); 6329 var location = that.params['node'].getAttribute('data-google-location'); 6330 var id = that.params['node'].getAttribute('data-google-id'); 6331 var icon = that.params['node'].getAttribute('data-google-icon'); 6332 that.params['zoom'] = parseInt(that.params['node'].getAttribute('data-google-zoom')); 6333 that.params['url'] = that.params['node'].getAttribute('data-google-url'); 6334 var style = cm.parseJSON(styles); 6335 // 6336 /*if(typeof google === 'undefined'){ 6337 cm.errorLog({ 6338 'type' : 'error', 6339 'name' : 'App.ModuleGoogleMap', 6340 'message' : 'ERROR: Google API is not defined.' 6341 }); 6342 }*/ 6343 6344 6345 if(location && location.length) { 6346 location = cm.parseJSON(atob(location)); 6347 that.renderMap(location, address, style, icon); 6348 } else { 6349 cm.ajax({ 6350 'method' : 'get', 6351 'type' : 'json', 6352 'url' : '//maps.google.com/maps/api/geocode/json?address='+address+'&key='+window.config.googlemap.apikey, 6353 'headers' : null, 6354 'onSuccess' : function(response) { 6355 if (response && response.status == 'OK' && response.results.length) { 6356 var location = response.results[0].geometry.location; 6357 var txt_loc = JSON.stringify(location); 6358 that.params['node'].setAttribute('data-google-location', btoa(txt_loc)); 6359 // cm.ajax({ 6360 // 'method' : 'get', 6361 // 'type' : 'json', 6362 // 'url' : that.params['url']+'?geocode='+txt_loc, 6363 // }); 6364 6365 that.renderMap(location, address, style, icon); 6366 } 6367 } 6368 }); 6369 } 6370 6371 return that; 6372 }; 6373 6374 classProto.renderMap = function(location, address, style, icon) { 6375 var that = this; 6376 var mapOptions = { 6377 zoom: that.params['zoom'], 6378 center: location, 6379 styles: style 6380 }; 6381 that.components['map'] = new google.maps.Map(that.params['node'], mapOptions); 6382 that.components['marker'] = new google.maps.Marker({ 6383 position: location, 6384 map: that.components['map'], 6385 title: address 6386 }); 6387 if (icon){ 6388 that.components['marker'].setIcon(icon); 6389 } 6390 return that; 6391 }; 6392 6393 classProto.onRedraw = function(){ 6394 var that = this; 6395 if(that.components['map']){ 6396 var center = that.components['map'].getCenter(); 6397 google.maps.event.trigger(that.components['map'], "resize"); 6398 that.components['map'].setCenter(center); 6399 } 6400 return that; 6401 }; 6402}); 6403 6404 6405Collector.add('google-map-form', function (node) { 6406 var nodes = cm.getNodes(node); 6407 6408 function IsJsonString(str) { 6409 try { 6410 JSON.parse(str); 6411 } catch (e) { 6412 return false;
6413 } 6414 6415 return true; 6416 } 6417 6418 function get_static_style(styles) { 6419 if (!styles) { 6420 return ''; 6421 } 6422 var result = []; 6423 styles.forEach(function(v, i, a){ 6424 var style=''; 6425 try { 6426 if (v.stylers.length > 0) { // Needs to have a style rule to be valid. 6427 style += (v.hasOwnProperty('featureType') ? 'feature:' + v.featureType : 'feature:all') + '|'; 6428 style += (v.hasOwnProperty('elementType') ? 'element:' + v.elementType : 'element:all') + '|'; 6429 v.stylers.forEach(function(val, i, a){ 6430 var propertyname = Object.keys(val)[0]; 6431 var propertyval = val[propertyname].toString().replace('#', '0x'); 6432 style += propertyname + ':' + propertyval + '|'; 6433 }); 6434 } 6435 result.push('style='+encodeURIComponent(style)); 6436 } 6437 catch (e) { 6438 cm.log('Style rule is not valid.'); 6439 } 6440 }); 6441 var r = "&"+result.join('&'); 6442 return r; 6443 } 6444 6445 var preview = nodes['GoogleMapForm']['preview']; 6446 preview.style.display = 'none'; 6447 6448 var zoomHandler = function (classObject) { 6449 var zoom = classObject; 6450 6451 var location = nodes['GoogleMapForm']['location'], 6452 img = document.createElement("img"), 6453 startTime = 0, 6454 styles = nodes['GoogleMapForm']['style']; 6455 6456 img.setAttribute('width', '100%'); 6457 img.setAttribute('height', '250px'); 6458 6459 var params = { 6460 'default': preview.getAttribute('data-default'), 6461 'mapURL': function (location, style, zoom) { 6462 var url = preview.getAttribute('data-map'); 6463 var jsonStyle = null; 6464 if (IsJsonString(style)) { 6465 jsonStyle = JSON.parse(style); 6466 } 6467 6468 return url.concat('?params=', btoa(JSON.stringify({loc: location, style: get_static_style(jsonStyle), zoom: zoom}))) 6469 }, 6470 }; 6471 6472 if (location.value === '') { 6473 img.setAttribute("src", params.mapURL(params.default, styles.value, zoom.get())); 6474 preview.parentNode.appendChild(img); 6475 } else { 6476 img.setAttribute("src", params.mapURL(location.value, styles.value, zoom.get())); 6477 preview.parentNode.appendChild(img); 6478 } 6479 6480 var changeZoom = function () { 6481 img.setAttribute("src", params.mapURL(location.value, styles.value, zoom.get())); 6482 preview.parentNode.appendChild(img); 6483 }; 6484 6485 var changeLoc = function (endTime, loc_temp) { 6486 if (startTime && ((endTime - startTime) > 300)) 6487 { 6488 setTimeout(function () { 6489 if (loc_temp == location.value) { 6490 img.setAttribute("src", params.mapURL(location.value, styles.value, zoom.get())); 6491 preview.parentNode.appendChild(img); 6492 } 6493 }, 1000) 6494 startTime = endTime; 6495 } 6496 else if (!startTime) 6497 { 6498 startTime = new Date().getTime(); 6499 } 6500 }; 6501 var changeStyle = function (endTime, style_temp) { 6502 if (startTime && ((endTime - startTime) > 300)) 6503 { 6504 setTimeout(function () { 6505 if (style_temp == styles.value) { 6506 img.setAttribute("src", params.mapURL(location.value, styles.value, zoom.get())); 6507 preview.parentNode.appendChild(img); 6508 } 6509 }, 1000); 6510 startTime = endTime; 6511 } 6512 else if (!startTime) 6513 { 6514 startTime = new Date().getTime(); 6515 } 6516 }; 6517 6518 zoom.addEvent('onChange', changeZoom); 6519 6520 location.addEventListener('keyup', function () { 6521 geocode = cm.getEl('google-map-geocode'); 6522 //geocode.value = ''; 6523 changeLoc(new Date().getTime(), location.value) 6524 }, true); 6525 styles.addEventListener('keyup', function () { 6526 changeStyle(new Date().getTime(), styles.value) 6527 }, true); 6528 }; 6529 new cm.Finder('Com.Select', 'zoom', nodes['GoogleMapForm'].container, zoomHandler); 6530 new cm.Finder('Com.Select', 'general[zoom]', nodes['GoogleMapForm'].container, zoomHandler); 6531 6532 var typeHandler = function (classObject) { 6533 var type = classObject; 6534 type.addEvent('onChange', function(element, value) { 6535 if (value == 'static') { 6536 cm.removeClass(nodes['GoogleMapForm'].width, 'display-none');
6537 cm.addClass(nodes['GoogleMapForm'].icon, 'display-none'); 6538 } else { 6539 cm.addClass(nodes['GoogleMapForm'].width, 'display-none'); 6540 cm.removeClass(nodes['GoogleMapForm'].icon, 'display-none'); 6541 } 6542 /*if (width.value == '') { 6543 width.value = '200'; 6544 }*/ 6545 }); 6546 6547 type.triggerEvent('onChange', type.get()); 6548 }; 6549 new cm.Finder('Com.Select', 'type', nodes['GoogleMapForm'].container, typeHandler); 6550 new cm.Finder('Com.Select', 'general[type]', nodes['GoogleMapForm'].container, typeHandler); 6551}) 6552 6553 6554!function () { 6555 if( typeof CKEDITOR !== "undefined" ) { 6556 CKEDITOR.config.extraPlugins += (CKEDITOR.config.extraPlugins == '') ? 'gmap' : ',gmap'; 6557 } 6558 Collector.add('google-dynamic-map', function (node) { 6559 new App.ModuleGoogleMap({ 6560 'node' : node 6561 }); 6562 }); 6563}(); 6564 6565 6566 6567 6568!function() { 6569 cm.define('App.HubspotRecent', { 6570 'extend' : 'Com.AbstractController' 6571 }, function (params) { 6572 var that = this; 6573 // Call parent class construct 6574 Com.AbstractController.apply(that, arguments); 6575 }); 6576 6577 cm.getConstructor('App.HubspotRecent', function(classConstructor, className, classProto) { 6578 var _inherit = classProto._inherit; 6579 6580 classProto.renderViewModel = function () { 6581 var that = this; 6582 6583 _inherit.prototype.renderViewModel.apply(that, arguments); 6584 6585 var uri = that.params['node'].getAttribute('data-href'); 6586 6587 var viewList = new Com.Gridlist({ 6588 'node' : that.params['node'], 6589 'sort' : false, 6590 'perPage' : 200, 6591 'ajax' : { 6592 'url' : uri, 6593 'params' : { 6594 'page' : '%page%', 6595 'perPage' : '%perPage%' 6596 } 6597 }, 6598 'langs' : { 6599 'empty' : 'Items not found', 6600 }, 6601 'cols' : [ 6602 {'key' : 'email', 'type' : 'text', 'width' : 'auto', 'title' : 'Email'}, 6603 {'key' : 'firstname', 'type' : 'text', 'width' : 'auto', 'title' : 'First name'}, 6604 {'key' : 'lastname', 'type' : 'text', 'width' : 'auto', 'title' : 'Last name'}, 6605 {'key' : 'company', 'type' : 'text', 'width' : '15%', 'title' : 'Company'}, 6606 {'key' : 'created', 'type' : 'text', 'width' : '15%', 'title' : 'Created'}, 6607 {'key' : 'exists', 'type' : 'html', 'width' : '15%', 'title' : 'Status'} 6608 ] 6609 }); 6610 6611 return that; 6612 } 6613 }); 6614 6615 cm.define('App.HubspotList', { 6616 'extend' : 'Com.AbstractController' 6617 }, function (params) { 6618 var that = this; 6619 // Call parent class construct 6620 Com.AbstractController.apply(that, arguments); 6621 }); 6622 6623 cm.getConstructor('App.HubspotList', function(classConstructor, className, classProto) { 6624 var _inherit = classProto._inherit; 6625 6626 classProto.renderViewModel = function() { 6627 var that = this; 6628 6629 _inherit.prototype.renderViewModel.apply(that, arguments); 6630 6631 var importContact = function() { 6632 var overlay = new Com.Overlay(); 6633 6634 var data = viewList.getCheckedData(); 6635 cm.ajax({ 6636 'method': 'POST', 6637 'type' : 'text', 6638 'url' : that.params['import'], 6639 'params': cm.obj2URI({'contact':data}), 6640 'onSuccess' : function(response, load) { 6641 overlay.close(); 6642 6643 if (load.target.status === 200) { 6644 var result = cm.parseJSON(response); 6645 if (result && result.result) { 6646 Request.fire('dialog', result.details); 6647 } 6648 } 6649 }, 6650 'onError' : function(response, load) { 6651 if (load && load.target.status === 403) { 6652 window.location = window.config.url +'/user/login'; 6653 } 6654 6655 overlay.close(); 6656 } 6657 }); 6658 }; 6659 6660 var viewList = new Com.Gridlist({ 6661 'node' : that.params['node'], 6662 'sort' : false, 6663 'perPage' : 200, 6664 'ajax' : { 6665 'url' : that.params['contact'], 6666 'params' : { 6667 'page' : '%page%',
6668 'perPage' : '%perPage%' 6669 } 6670 }, 6671 'langs' : { 6672 'empty' : 'Items not found', 6673 }, 6674 'cols' : [ 6675 {'type' : 'checkbox', 'width' : '48'}, 6676 {'key' : 'email', 'type' : 'text', 'width' : 'auto', 'title' : 'Email'}, 6677 {'key' : 'firstname', 'type' : 'text', 'width' : 'auto', 'title' : 'First name'}, 6678 {'key' : 'lastname', 'type' : 'text', 'width' : 'auto', 'title' : 'Last name'}, 6679 {'key' : 'company', 'type' : 'text', 'width' : '15%', 'title' : 'Company'}, 6680 {'key' : 'created', 'type' : 'text', 'width' : '15%', 'title' : 'Created'}, 6681 {'key' : 'exists', 'type' : 'html', 'width' : '15%', 'title' : 'Status'} 6682 ], 6683 'actions' : [ 6684 {'label':'Import', 'callback':importContact}, 6685 ] 6686 }); 6687 6688 return that; 6689 }; 6690 }); 6691 6692 Collector.add('hubspot-list', function(node) { 6693 new App.HubspotList({'node':node}); 6694 }); 6695 6696 Collector.add('hubspot-recent', function(node) { 6697 new App.HubspotRecent({'node':node}); 6698 }); 6699 6700 Collector.add('hubspot-chart', function(node) { 6701 new App.ChartHubspotContacs({'node':node}); 6702 }); 6703 6704 Collector.add('Hubspot.Grid', function (node) { 6705 var options = { 6706 'node': node, 6707 'events': { 6708 'onRenderEnd': function (that, page) { 6709 Collector.construct(page['container']); 6710 } 6711 }, 6712 'Com.Toolbar': { 6713 'events': { 6714 'onProcessEnd': function (component) { 6715 Collector.construct(component['nodes']['container']); 6716 } 6717 } 6718 } 6719 }; 6720 6721 var params = node.getAttribute('data-config'); 6722 params = cm.parseJSON(params); 6723 if (params) { 6724 options = cm.merge(options, params); 6725 } 6726 6727 new Com.Gridlist(options); 6728 }); 6729 6730 Collector.add('hubspot-change-value', function (node) { 6731 var params = cm.parseJSON(node.getAttribute('data-config')); 6732 6733 new cm.Finder('Com.Select', 'general[formId]', node, function (classObject) { 6734 classObject.addEvent('onChange', function (element, value) { 6735 if(value){ 6736 window.jQuery('[name="general[hs_submissions]"]').val(params[value]['submissions']); 6737 if(params[value]['thank_you']){ 6738 window.jQuery('[type="radio"][value="message"]').click(); 6739 } 6740 if(params[value]['redirect']){ 6741 window.jQuery('[type="radio"][value="redirect"]').click(); 6742 } 6743 window.jQuery('[name="general[message]"]').val(params[value]['thank_you']); 6744 window.jQuery('[name="general[redirect]"]').val(params[value]['redirect']); 6745 window.jQuery('[name="general[simplecontent]"]').attr("checked", params[value]['simplecontent'] ); 6746 window.jQuery('[name="general[captchaEnabled]"]').attr("checked", params[value]['captchaEnabled'] ); 6747 }else{ 6748 window.jQuery('[name="general[hs_submissions]"]').val(''); 6749 window.jQuery('[name="general[message]"]').val(''); 6750 window.jQuery('[name="general[redirect]"]').val(''); 6751 window.jQuery('[name="general[simplecontent]"]').attr("checked", false ); 6752 window.jQuery('[name="general[captchaEnabled]"]').attr("checked", false ); 6753 window.jQuery('[type="radio"][value="message"]').click(); 6754 } 6755 6756 }); 6757 }) 6758 6759 }) 6760 6761}(); 6762 6763 6764 6765!function($) { 6766 // Components 6767 Collector.add('form_image-gallery', function(node) { 6768 new App.FormImageGalery({ 6769 'node' : node 6770 }); 6771 }); 6772 6773 Collector.add('image-gallery-layout', function(node) { 6774 new Com.GalleryLayout({ 6775 'node':node, 6776 'events' : { 6777 'onChange' : function(gallery, data){ 6778 var id = data.current.link.getAttribute('data-id'); 6779 var div = $(node).parent(); 6780 var button = div.parent().find('[data-type=editbutton]').get(0); 6781 if (button){ 6782 var href = $(button).attr('data-href'); 6783 $(button).attr('href', href+'/'+id); 6784 } 6785 button = div.parent().find('[data-type=deletebutton]').get(0); 6786 if (button){ 6787 var href = $(button).attr('data-href'); 6788 $(button).attr('href', href+'/'+id); 6789 } 6790 } 6791 } 6792 }); 6793 }); 6794 6795 Collector.add('image-gallery-popup', function(node) { 6796 new Com.GalleryPopup({'node' : node}); 6797 }); 6798 6799 Collector.add('module_image-gallery', function (node) { 6800 new App.ModuleImageGallery({'node' : node}); 6801 }); 6802 6803}(window.jQuery); 6804 6805 6806 6807!function () { 6808 Collector.add('module__logocarousel', function (node) { 6809 new Module.LogoCarousel({'node':node}); 6810 }); 6811}(window.jQuery); 6812 6813 6814cm.define('App.MemberDirectoryForm', { 6815 'modules': [ 6816 'Params', 6817 'Events', 6818 'Langs', 6819 'DataConfig', 6820 'DataNodes'
6821 ], 6822 'events': [ 6823 'onRender' 6824 ], 6825 'params': { 6826 'node': cm.Node('div'), 6827 'name': '' 6828 } 6829}, 6830function (params) { 6831 var that = this; 6832 that.components = {}; 6833 var init = function () { 6834 that.setParams(params); 6835 that.convertEvents(that.params['events']); 6836 that.getDataNodes(that.params['node']); 6837 that.getDataConfig(that.params['node']); 6838 render(); 6839 that.triggerEvent('onRender'); 6840 }; 6841 6842 var render = function () { 6843 optionSelectUsers(); 6844 cm.find('Com.Select', null, that.nodes['optionSelectUsers'], function (classObject) { 6845 that.components['optionSelectUsers'] = classObject; 6846 that.components['optionSelectUsers'].addEvent('onChange', function (select, value) { 6847 optionSelectUsers(select, value); 6848 }); 6849 classObject.triggerEvent('onChange', classObject.get()); 6850 }); 6851 6852 optionViewFields(); 6853 cm.find('Com.Select', null, that.nodes['optionViewFields'], function (classObject) { 6854 that.components['optionViewFields'] = classObject; 6855 that.components['optionViewFields'].addEvent('onChange', function (select, value) { 6856 optionViewFields(select, value); 6857 }); 6858 classObject.triggerEvent('onChange', classObject.get()); 6859 }); 6860 }; 6861 6862 var optionSelectUsers = function (event, active) { 6863 if (active == 'auto') { 6864 cm.removeClass(that.nodes['groups'],'display-none'); 6865 cm.removeClass(that.nodes['roles'],'display-none'); 6866 cm.removeClass(that.nodes['department'],'display-none'); 6867 cm.removeClass(that.nodes['status'],'display-none'); 6868 } else { 6869 cm.addClass(that.nodes['groups'],'display-none'); 6870 cm.addClass(that.nodes['roles'],'display-none'); 6871 cm.addClass(that.nodes['department'],'display-none'); 6872 cm.addClass(that.nodes['status'],'display-none'); 6873 } 6874 }; 6875 6876 var optionViewFields = function (event, active) { 6877 if (active == 'manually') { 6878 cm.removeClass(that.nodes['viewFields'],'display-none'); 6879 } else { 6880 cm.addClass(that.nodes['viewFields'],'display-none'); 6881 } 6882 }; 6883 6884 /* ******* MAIN ******* */ 6885 6886 init(); 6887 6888}); 6889 6890 6891 6892!function($) { 6893 6894 Collector.add('member_directory_form', function (node) { 6895 new App.MemberDirectoryForm({'node' : node}); 6896 }); 6897 6898 cm.onReady(function(){ 6899 var select = Com.GetSelect('MemberDirectorySort'); 6900 if (select){ 6901 select.addEvent('onSelect', function(node){ 6902 $(select.getNodes().hidden).closest('form').submit(); 6903 }); 6904 } 6905 }); 6906 6907 6908 Collector.add('wgsearch', function(node){ 6909 $(node).click(function() { 6910 cm.getByAttr('data-element','wgsearch-submit').item(0).click(); 6911 }); 6912 6913 }); 6914 6915 Collector.add('active', function(node) { 6916 if(node.id == 'memberdirectory-append') { 6917 $(node).bind('click', function() { 6918 $(node).parents('form:first').find('[data-element="dialog-close"]').trigger('click'); 6919 }); 6920 } 6921 }); 6922 6923 Collector.add('memberdirectory-show', function(node) { 6924 var element = $(node).find('a'); 6925 var block = $(node).find('ul').get(0); 6926 6927 var setLabel = function(type) { 6928 var text = element.attr('data-'+ type); 6929 element.text(text); 6930 } 6931 6932 element.bind('click', function() { 6933 if(block.style.display == 'none') { 6934 setLabel('hide'); 6935 $(block).show(); 6936 } 6937 else { 6938 setLabel('show'); 6939 $(block).hide(); 6940 } 6941 }); 6942 }); 6943 6944 Collector.add('memberdirectory-select', function(node) { 6945 var element = $(node); 6946 var member = $('[name="member[]"]').get(0); 6947 element.bind('form-pre-serialize submit', function(e) { 6948 cm.forEach(member.options, function(option, index) { 6949 if(!option.selected) { 6950 option.selected = true; 6951 } 6952 }); 6953 6954 return true; 6955 }); 6956 6957 element.find('#member_toLeft').bind('click', function() { 6958 var right = $('[name="member[]"]').get(0); 6959 if(right.selectedIndex != -1) { 6960 var left = $('[name="users[]"]').get(0); 6961 var values = []; 6962 6963 cm.forEach(right.options, function(option, index) { 6964 if(option.selected) { 6965 values.push(option); 6966 6967 left.appendChild(new Option(option.text, option.value)); 6968 } 6969 }); 6970 6971 if(values.length) { 6972 cm.forEach(values, function(option) { 6973 option.remove(); 6974 }); 6975 } 6976 } 6977 }); 6978 6979 element.find('#member_toRight').bind('click', function() { 6980 var left = $('[name="users[]"]').get(0); 6981 if(left.selectedIndex != -1) { 6982 var right = $('[name="member[]"]').get(0); 6983 var values = []; 6984 6985 cm.forEach(left.options, function(option, index) { 6986 if(option.selected) { 6987 values.push(option); 6988 6989 var set = new Option(option.text, option.value); 6990 set.selected = true; 6991 6992 right.appendChild(set); 6993 } 6994 }); 6995 6996 if(values.length) { 6997 cm.forEach(values, function(option) { 6998 option.remove(); 6999 }); 7000 } 7001 } 7002 }); 7003 }); 7004 7005}(window.jQuery); 7006 7007 7008 7009(function () { 7010 7011 Collector.add('microsite-hint', function(node) { 7012 var params = cm.parseJSON(node.getAttribute('data-config')); 7013 var select; 7014 var updateHint = function(e){ 7015 cm.find('Com.Select', 'type', node.parentNode.parentNode.parentNode, function(classObject) { 7016 if (!select) { 7017 select = classObject; 7018 classObject.addEvent('onChange', function (self, value) { 7019 updateHint(); 7020 }); 7021 } 7022 if(params[classObject.get()]!=undefined){ 7023 cm.remove(cm.getEl('hint')); 7024 if(node.value) { 7025 var template = params[classObject.get()].replace('%s', node.value); 7026 var hint = cm.strToHTML('<ul class="hint" id="hint"><li>' + template + '</li></ul>'); 7027 cm.insertAfter(hint, node); 7028 } 7029 } 7030 }); 7031 } 7032 cm.addEvent(node, 'keyup', updateHint); 7033 updateHint(); 7034 }, null, 800); 7035 7036})(); 7037 7038 7039cm.define('App.ShutterstockTemporaryForm', { 7040 'extend' : 'Com.AbstractController', 7041 'params' : { 7042 'renderStructure' : false, 7043 'embedStructureOnRender' : false, 7044 'controllerEvents' : true, 7045 'overlayConstructor' : 'Com.Overlay', 7046 'overlayParams' : { 7047 'autoOpen' : false, 7048 'lazy' : false 7049 }, 7050 'termsConstructor' : 'Com.Dialog', 7051 'termsParams' : { 7052 'autoOpen' : false 7053 } 7054 } 7055}, 7056function(params){ 7057 var that = this; 7058 // Call parent class construct in current context 7059 Com.AbstractController.apply(that, arguments); 7060}); 7061
7062cm.getConstructor('App.ShutterstockTemporaryForm', function(classConstructor, className, classProto, classInherit){ 7063 classProto.onConstructStart = function(){ 7064 var that = this; 7065 // Variables 7066 that.nodes = { 7067 'items' : [], 7068 'terms' : { 7069 'buttons' : {} 7070 }, 7071 'buttons' : {} 7072 }; 7073 that.items = []; 7074 that.selected = []; 7075 }; 7076 7077 classProto.renderViewModel = function(){ 7078 var that = this; 7079 // Call parent method - renderViewModel 7080 classInherit.prototype.renderViewModel.apply(that, arguments); 7081 // Init overlay 7082 cm.getConstructor(that.params['overlayConstructor'], function(classConstructor){ 7083 that.components['overlay'] = new classConstructor(that.params['overlayParams']); 7084 }); 7085 // Init terms dialog 7086 cm.getConstructor(that.params['termsConstructor'], function(classConstructor){ 7087 that.components['terms'] = new classConstructor(that.params['termsParams']); 7088 }); 7089 // Process terms 7090 that.processTerms(); 7091 // Process items 7092 that.processItems(); 7093 // Process form 7094 that.processForm(); 7095 }; 7096 7097 /*** ITEMS ***/ 7098 7099 classProto.processItems = function(){ 7100 var that = this; 7101 cm.forEach(that.nodes['items'], function(item){ 7102 that.processItem(item); 7103 }); 7104 }; 7105 7106 classProto.processItem = function(item){ 7107 var that = this; 7108 cm.addEvent(item['ComImageBox']['checkbox'], 'change', function(){ 7109 if(item['ComImageBox']['checkbox'].checked){ 7110 that.selectItem(item); 7111 }else{ 7112 that.deselectItem(item); 7113 } 7114 }); 7115 }; 7116 7117 classProto.selectItem = function(item){ 7118 var that = this; 7119 cm.addClass(item['ComImageBox']['container'], 'active'); 7120 that.selected = cm.arrayAdd(that.selected, item); 7121 that.toggleButtons(); 7122 }; 7123 7124 classProto.deselectItem = function(item){ 7125 var that = this; 7126 cm.removeClass(item['ComImageBox']['container'], 'active'); 7127 that.selected = cm.arrayRemove(that.selected, item); 7128 that.toggleButtons(); 7129 }; 7130 7131 /*** BUTTONS ***/ 7132 7133 classProto.toggleButtons = function(){ 7134 var that = this; 7135 if(that.selected.length === 0){ 7136 cm.addClass(that.nodes.buttons['container'], 'is-hidden'); 7137 }else{ 7138 cm.removeClass(that.nodes.buttons['container'], 'is-hidden'); 7139 } 7140 }; 7141 7142 /*** TERMS ***/ 7143 7144 classProto.processTerms = function(){ 7145 var that = this; 7146 // Tooltip 7147 cm.addEvent(that.nodes['terms']['tooltip'], 'click', function(e){ 7148 cm.preventDefault(e); 7149 that.openTerms({'title' : true, 'content' : true, 'buttons' : false}); 7150 }); 7151 cm.addEvent(that.nodes['terms']['buttons']['cancel'], 'click', function(e){ 7152 cm.preventDefault(e); 7153 that.closeTerms(); 7154 }); 7155 cm.addEvent(that.nodes['terms']['buttons']['submit'], 'click', function(e){ 7156 cm.preventDefault(e); 7157 that.purchase(); 7158 }); 7159 }; 7160 7161 classProto.openTerms = function(params){ 7162 var that = this; 7163 // Validate 7164 params = cm.merge({ 7165 'title' : true, 7166 'content' : true, 7167 'buttons' : false 7168 }, params); 7169 // Set dialog content 7170 if(params['title']){ 7171 that.components['terms'].setTitle(that.nodes['terms']['title']) 7172 }else{ 7173 cm.remove(that.nodes['terms']['title']); 7174 } 7175 if(params['content']){ 7176 that.components['terms'].setContent(that.nodes['terms']['content']) 7177 }else{ 7178 cm.remove(that.nodes['terms']['content']); 7179 } 7180 if(params['buttons']){ 7181 that.components['terms'].setButtons(that.nodes['terms']['buttons']['container']) 7182 }else{ 7183 cm.remove(that.nodes['terms']['buttons']['container']); 7184 } 7185 // Open dialog 7186 that.components['terms'].open(); 7187 }; 7188 7189 classProto.closeTerms = function(){ 7190 var that = this; 7191 that.components['terms'].close(); 7192 }; 7193 7194 /*** FORM ***/ 7195 7196 classProto.processForm = function(){ 7197 var that = this; 7198 cm.addEvent(that.nodes['buttons']['delete'], 'click', function(e){ 7199 cm.preventDefault(e); 7200 that.delete(); 7201 }); 7202 cm.addEvent(that.nodes['buttons']['purchase'], 'click', function(e){ 7203 cm.preventDefault(e); 7204 that.openTerms({'title' : true, 'content' : true, 'buttons' : true}); 7205 }); 7206 cm.addEvent(that.nodes['container'], 'submit', function(e){ 7207 cm.preventDefault(e); 7208 }); 7209 }; 7210 7211 classProto.delete = function(){ 7212 var that = this; 7213 cm.appendChild( 7214 cm.node('input', {'type' : 'hidden', 'name' : 'delete', 'value' : '1'}), 7215 that.nodes['container'] 7216 ); 7217 that.components['overlay'].open(); 7218 that.nodes['container'].submit(); 7219 }; 7220 7221 classProto.purchase = function(){ 7222 var that = this; 7223 cm.appendChild( 7224 cm.node('input', {'type' : 'hidden', 'name' : 'purchase', 'value' : '1'}), 7225 that.nodes['container'] 7226 ); 7227 that.components['overlay'].open(); 7228 that.nodes['container'].submit(); 7229 }; 7230}); 7231 7232(function () { 7233 cm.addEvent(document, 'contextmenu', function(e){ 7234 var target = cm.getEventTarget(e), 7235 url; 7236 if(cm.isNode(target) && target.tagName.toLowerCase() === 'img'){ 7237 url = target.getAttribute('src'); 7238 } 7239 if(!cm.isEmpty(url) && url.indexOf('/shutterstock/') > -1){ 7240 cm.preventDefault(e); 7241 } 7242 }); 7243 7244 cm.setParams('App.ImageInput', { 7245 'fileUploaderParams' : { 7246 'params' : { 7247 'stock' : true 7248 } 7249 } 7250 }); 7251 7252 cm.setParams('App.ShutterstockManager', {
7253 'categoriesRequestParams' : { 7254 'ajax' : { 7255 'url' : '/shutterstock-api/images/categories' 7256 } 7257 }, 7258 'paginationParams' : { 7259 'ajax' : { 7260 'url' : '/shutterstock-api/images/search/%page%', 7261 'urlPurchased' : '/shutterstock-api/images/src' 7262 } 7263 } 7264 }); 7265 7266 cm.setParams('App.ShutterstockStats', { 7267 'adminLink' : '/admin/shutterstock/' 7268 }); 7269 7270 Collector.add('shutterstock-temporary-form', function(node){ 7271 new App.ShutterstockTemporaryForm({ 7272 'node' : node 7273 }); 7274 }); 7275})(); 7276 7277 7278cm.define('App.ModuleSlider', { 7279 'modules' : [ 7280 'Params', 7281 'Events', 7282 'Langs', 7283 'DataConfig', 7284 'DataNodes', 7285 'Stack' 7286 ], 7287 'events' : [ 7288 'onRender', 7289 'onEnableEditing', 7290 'onEnableEditable', 7291 'onDisableEditing', 7292 'onDisableEditable' 7293 ], 7294 'params' : { 7295 'node' : cm.node('div'), 7296 'name' : '', 7297 'isEditing' : false, 7298 'customEvents' : true 7299 }, 7300 'strings' : { 7301 'counter' : '%id% / %total%' 7302 } 7303}, 7304function(params){ 7305 var that = this; 7306 7307 that.nodes = { 7308 'buttons' : { 7309 'edit' : cm.node('div'), 7310 'delete' : cm.node('div'), 7311 'prev' : cm.node('div'), 7312 'next' : cm.node('div'), 7313 'title' : cm.node('div'), 7314 'counter' : cm.node('div') 7315 } 7316 }; 7317 that.components = {}; 7318 that.isEditing = null; 7319 7320 var init = function(){ 7321 that.setParams(params); 7322 that.convertEvents(that.params['events']); 7323 that.getDataNodes(that.params['node']); 7324 that.getDataConfig(that.params['node']); 7325 that.addToStack(that.params['node']); 7326 render(); 7327 that.triggerEvent('onRender'); 7328 }; 7329 7330 var render = function(){ 7331 that.nodes['buttons']['prev'].style.display = 'none'; 7332 that.nodes['buttons']['next'].style.display = 'none'; 7333 that.nodes['buttons']['edit'].style.display = 'none'; 7334 that.nodes['buttons']['delete'].style.display = 'none'; 7335 7336 new cm.Finder('Com.Slider', that.params['name'], that.nodes['container'], function (classObject) { 7337 that.components['slider'] = classObject; 7338 process(); 7339 }); 7340 7341 }; 7342 7343 var process = function(){ 7344 that.nodes['buttons']['prev'].style.display = ''; 7345 that.nodes['buttons']['next'].style.display = ''; 7346 that.nodes['buttons']['edit'].style.display = ''; 7347 that.nodes['buttons']['delete'].style.display = ''; 7348 7349 var current; 7350 if(current = that.components['slider'].get(that.components['slider'].current)){ 7351 bindControls(that.components['slider'], {'current' : current}); 7352 } 7353 // Add events 7354 cm.addEvent(that.nodes['buttons']['prev'], 'click', that.components['slider'].prev); 7355 cm.addEvent(that.nodes['buttons']['next'], 'click', that.components['slider'].next); 7356 that.components['slider'].addEvent('onChange', bindControls); 7357 // Add custom event 7358 if(that.params['customEvents']){ 7359 cm.customEvent.add(that.params['node'], 'enableEditable', function(){ 7360 that.enableEditing(); 7361 }); 7362 cm.customEvent.add(that.params['node'], 'disableEditable', function(){ 7363 that.disableEditing(); 7364 }); 7365 } 7366 // Editing 7367 that.params['isEditing'] && that.enableEditing(); 7368 }; 7369 7370 var bindControls = function(slider, data){ 7371 var item = data.current, 7372 id = item['nodes']['container'].getAttribute('data-id'), 7373 title = item['nodes']['container'].getAttribute('title'), 7374 counter = that.lang('counter', { 7375 '%id%' : slider.current + 1, 7376 '%total%' : slider.items.length 7377 }); 7378 // Bind buttons 7379 that.nodes['buttons']['edit'].setAttribute('href', that.nodes['buttons']['edit'].getAttribute('data-base-url')+ '/' + id); 7380 that.nodes['buttons']['delete'].setAttribute('href', that.nodes['buttons']['delete'].getAttribute('data-base-url')+ '/' + id); 7381 // Counter 7382 that.nodes['buttons']['counter'].textContent = counter; 7383 that.nodes['buttons']['title'].textContent = title; 7384 }; 7385 7386 /* ******* MAIN ******* */ 7387 7388 that.enableEditing = function(){ 7389 if(!cm.isBoolean(that.isEditing) || !that.isEditing){ 7390 that.isEditing = true; 7391 cm.addClass(that.params['node'], 'is-editing is-editable'); 7392 that.triggerEvent('onEnableEditing'); 7393 that.triggerEvent('onEnableEditable'); 7394 } 7395 return that; 7396 }; 7397 7398 that.disableEditing = function(){ 7399 if(!cm.isBoolean(that.isEditing) || that.isEditing){ 7400 that.isEditing = false;
7401 cm.removeClass(that.params['node'], 'is-editing is-editable'); 7402 that.triggerEvent('onDisableEditing'); 7403 that.triggerEvent('onDisableEditable'); 7404 } 7405 return that; 7406 }; 7407 7408 init(); 7409}); 7410 7411(function ($) { 7412 Collector.add('slider-wrapper-preview', function (node) { 7413 var params = node.getAttribute('data-config'); 7414 if(params){ 7415 params = JSON.parse(params); 7416 var wrapperview = Com.GetSelect('general[wrapperview]'); 7417 if(!wrapperview){ 7418 wrapperview = Com.GetSelect('wrapperview'); 7419 } 7420 var image = cm.node('img', {'src': params[wrapperview.get()]}); 7421 cm.insertBefore(image, node); 7422 wrapperview.addEvent('onSelect', function(select, active){ 7423 cm.remove(image); 7424 image = cm.node('img', {'src': params[active]}); 7425 cm.insertBefore(image, node); 7426 }); 7427 node.style.display = 'none'; 7428 } 7429 }); 7430 7431 Collector.add('slider', function (node) { 7432 new Com.Slider({'node': node}); 7433 }); 7434 7435 Collector.add('module_slider', function (node) { 7436 new App.ModuleSlider({'node' : node}); 7437 }); 7438 7439 Collector.add('select', function(node) { 7440 var select; 7441 if (node.name === 'dimensions') { 7442 select = Com.GetSelect('dimensions'); 7443 } 7444 if (node.name === 'general[dimensions]') { 7445 select = Com.GetSelect('general[dimensions]'); 7446 } 7447 if (select) { 7448 var onchange = function (element, value) { 7449 var aspect, specific, content; 7450 if (node.name === 'dimensions') { 7451 aspect = $(cm.getByName('dimensionsaspect')).closest('dl'); 7452 specific = $(cm.getByName('dimensionsspecific')).closest('dl'); 7453 content = $(cm.getByName('dimensionscontent')).closest('dl'); 7454 }else{ 7455 aspect = $(cm.getByName('general[dimensionsaspect]')).closest('dl'); 7456 specific = $(cm.getByName('general[dimensionsspecific]')).closest('dl'); 7457 content = $(cm.getByName('general[dimensionscontent]')).closest('dl'); 7458 } 7459 switch (value){ 7460 case 'aspect': 7461 aspect.show(); 7462 specific.hide(); 7463 content.hide(); 7464 break; 7465 case 'specific': 7466 aspect.hide(); 7467 specific.show(); 7468 content.hide(); 7469 break; 7470 case 'content': 7471 aspect.hide(); 7472 specific.hide(); 7473 content.show(); 7474 break; 7475 } 7476 }; 7477 select.addEvent('onChange', onchange); 7478 onchange(select, select.get()); 7479 } 7480 }); 7481 7482 Collector.add('select', function(node) { 7483 if (node.name === 'imagePosition') { 7484 var select = Com.GetSelect('imagePosition'); 7485 if (select) { 7486 var onchange = function (element, value) { 7487 if ('predefined' == value) { 7488 $(cm.getByName('predefined').item(0)).closest('dl').show(); 7489 $(cm.getByName('custom').item(0)).closest('dl').hide(); 7490 } else { 7491 $(cm.getByName('predefined').item(0)).closest('dl').hide(); 7492 $(cm.getByName('custom').item(0)).closest('dl').show(); 7493 } 7494 }; 7495 select.addEvent('onChange', onchange); 7496 onchange(select, select.get()); 7497 } 7498 } 7499 }); 7500 7501})(window.jQuery); 7502 7503 7504 7505(function($) { 7506 Request.add('socialmedia/favorite', function(details, context) { 7507 if(!details) { 7508 return null; 7509 } 7510 7511 var node = context.node; 7512 if('active' in details) { 7513 node.setAttribute('href', details.active); 7514 } 7515 7516 if('count' in details) { 7517 var count = node.querySelector('.count'); 7518 if(count) count.innerHTML = details.count; 7519 } 7520 }); 7521 7522 Collector.add('socialrating', function(node) { 7523 var rating = cm.getNodes(node); 7524 cm.forEach(rating['rating'], function(button) { 7525 cm.addEvent(button, 'click', function(e) { 7526 Request.send(button.getAttribute('href'), {'link':location.href}, 'get', {'node':node}); 7527 cm.preventDefault(e); 7528 }); 7529 }); 7530 }); 7531 7532 Request.add('socialmedia/rating', function(details, context) { 7533 if('content' in details) { 7534 var block = context['node']; 7535 cm.clearNode(block); 7536 7537 var rating = cm.strToHTML(details['content']); 7538 block.appendChild(rating); 7539 7540 Collector.construct(block); 7541 } 7542 }); 7543})(window.jQuery); 7544 7545 7546 7547cm.define('App.FormVideoGallery', { 7548 'modules': [ 7549 'Params', 7550 'Events', 7551 'Langs', 7552 'DataConfig', 7553 'DataNodes'
7554 ], 7555 'events': [ 7556 'onRender' 7557 ], 7558 'params': { 7559 'node': cm.Node('div'), 7560 'name': '' 7561 } 7562}, 7563function (params) { 7564 var that = this; 7565 7566 that.nodes = { 7567 'items' : cm.node('div'), 7568 'form' : cm.node('div'), 7569 'buttons' : {} 7570 }; 7571 7572 var init = function () { 7573 that.setParams(params); 7574 that.convertEvents(that.params['events']); 7575 that.getDataNodes(that.params['node']); 7576 that.getDataConfig(that.params['node']); 7577 render(); 7578 that.triggerEvent('onRender'); 7579 }; 7580 7581 var render = function () { 7582 Request.add('videogallery-search-action', function (details, context) { 7583 var content = cm.strToHTML(details['form']); 7584 if ('videogallery-added' == content.className) { 7585 cm.clearNode(that.nodes['items']); 7586 cm.appendChild(content, that.nodes['items']); 7587 that.nodes['buttons']['submit'].className = 'button'; 7588 } else { 7589 cm.clearNode(that.nodes['items']); 7590 cm.appendChild(content, that.nodes['items']); 7591 that.nodes['buttons']['submit'].className = 'button display-none'; 7592 } 7593 Collector.construct(content); 7594 }); 7595 7596 cm.addEvent(that.nodes['buttons']['videogallery-search'], 'click', function(e){ 7597 cm.preventDefault(e); 7598 Request.send(that.nodes['form'].action, cm.getFDO(that.nodes['form']), 'post', {}); 7599 }); 7600 }; 7601 7602 /* ******* MAIN ******* */ 7603 7604 init(); 7605 7606}); 7607 7608 7609!function ($) { 7610 // Components 7611 Collector.add('vidoegallery-more', function (node) { 7612 var token = node.getAttribute('data-token'); 7613 $(node).bind('click', function () { 7614 var request = $.ajax({ 7615 'url': node.getAttribute('data-href'), 7616 'type': 'GET', 7617 'dataType': 'json', 7618 'data': { 7619 'token': token, 7620 'search': $('[name="search"]').val(), 7621 'specify': Com.GetSelect('video_specify').get(), 7622 'type': Com.GetSelect('video_type').get(), 7623 } 7624 }); 7625 7626 request.done(function (json) { 7627 var xhr = json.details.result; 7628 if (!xhr.token) { 7629 node.parentNode.removeChild(node); 7630 } 7631 7632 if (xhr.token != token) { 7633 token = xhr.token; 7634 } 7635 7636 var block = $('#videogallery-items').get(0); 7637 var indexes = block.childNodes.length; 7638 cm.forEach(xhr.items, function (item, i) { 7639 var idCheckbox = 'image' + (indexes + i); 7640 var element = cm.Node('li', 7641 cm.Node('div', {'class': 'pt__image'}, 7642 cm.Node('div', {'class': 'inner'}, 7643 cm.Node('img', {'src': item['thumbnail'], 'class': 'descr'}), 7644 cm.Node('div', {'class': 'icon x-large play centered'}), 7645 cm.Node('div', {'class': 'title'}, 7646 cm.Node('div', {'class': 'inner', 'innerHTML': item['title']}) 7647 ) 7648 ), 7649 cm.Node('label', {'for': idCheckbox}), 7650 cm.Node('div', {'class': 'pull top-left'}, 7651 cm.Node('input', {'id': idCheckbox, 'name': 'videoId[]', 'type': "checkbox", 'value': item['videoId']}) 7652 ) 7653 ) 7654 ); 7655 7656 block.appendChild(element); 7657 }); 7658 }); 7659 }); 7660 }); 7661 7662 Collector.add('video-gallery-popup', function(node) { 7663 new Com.GalleryPopup({'node' : node}); 7664 }); 7665 7666 7667 Collector.add('gallery-layout', function (node) { 7668 new Com.GalleryLayout({'node': node}); 7669 }); 7670 7671 Collector.add('videogallery-slider', function (node) { 7672 new Com.Slider({'node': node}); 7673 }); 7674 7675 var types = ['top', 'right', 'bottom', 'left', 'simple', 'grid']; 7676 var paths = {}; 7677 var preview = cm.Node('dd'); 7678 Collector.add('select', function (node) {
7679 if ('videoselect' !== node.getAttribute('data-id')) { 7680 return 0; 7681 } 7682 7683 if (node.name == 'style' || node.name == 'general[style]') { 7684 cm.forEach(types, function (item, index) { 7685 var attr = 'data-' + item; 7686 if (node.hasAttribute(attr)) { 7687 paths[item] = node.getAttribute(attr); 7688 } 7689 }); 7690 if (Object.keys(paths).length != types.length) { 7691 return false; 7692 } 7693 7694 if (node.name == 'general[style]') { 7695 $(cm.getByAttr('name', 'general[style]').item(0)).closest('li').append(cm.Node('dl', cm.Node('dt', 'Preview'), preview)); 7696 } else { 7697 var to = $('form#VideoGallery hr:first').get(0); 7698 to.parentNode.insertBefore(cm.Node('dl', cm.Node('dt', 'Preview'), preview), to); 7699 } 7700 7701 var style = Com.GetSelect('videogallery-style'); 7702 style.addEvent('onChange', function (self, value) { 7703 if (cm.isEmpty(value)) { 7704 var test = $(cm.getByAttr('name', 'style').item(0)).val(); 7705 if (test) 7706 value = test; 7707 7708 test = $(cm.getByAttr('name', 'general[style]').item(0)).val(); 7709 if (test) 7710 value = test; 7711 } 7712 $(preview).empty(); 7713 preview.appendChild(cm.Node('img', { 7714 'src': paths[value] 7715 })); 7716 }); 7717 7718 Com.GetSelect('videogallery-view').triggerEvent('onChange'); 7719 } 7720 else if (node.name == 'column' || node.name == 'general[column]') { 7721 var column = Com.GetSelect('videogallery-column'); 7722 column.addEvent('onChange', function (self, value) { 7723 if (cm.isEmpty(value)) { 7724 var test = $(cm.getByAttr('name', 'column').item(0)).val(); 7725 if (test) 7726 value = test; 7727 7728 test = $(cm.getByAttr('name', 'general[column]').item(0)).val(); 7729 if (test) 7730 value = test; 7731 } 7732 $(preview).empty(); 7733 var count = parseInt(value); 7734 var list = cm.Node('ul'); 7735 for (var i = 0; i < (count * 2); i++) { 7736 var item = cm.Node('li', 7737 cm.Node('div', {'class': 'pt__image'}, 7738 cm.Node('div', {'class': 'inner'}, 7739 cm.Node('img', { 7740 'class': 'descr', 7741 'style': 'width:' + (count == 1 ? '50%' : '100%'), 7742 'src': paths['grid'] 7743 }) 7744 ) 7745 )); 7746 7747 list.appendChild(item); 7748 } 7749 7750 preview.appendChild(cm.Node('div', {'class': 'pt__grid col-' + count + ' bottom'}, list)); 7751 }); 7752 } 7753 else if (node.name == 'view' || node.name == 'general[view]') { 7754 var column = $('#videogallery-column').parents('dl:first'); 7755 var rows = $('#videogallery-rows').parents('dl:first'); 7756 var paginator = $('#videogallery-paginator').parents('dl:first'); 7757 var style = $('#videogallery-style').parents('dl:first'); 7758 var caption = $('#videogallery-caption').parents('dl:first'); 7759 7760 var view = Com.GetSelect('videogallery-view'); 7761 7762 if(view) { 7763 view.addEvent('onChange', function (self, value) { 7764 if (cm.isEmpty(value)) { 7765 var test = $($(cm.getByAttr('name', 'view').item(0))).val(); 7766 if (test) 7767 value = test; 7768 7769 test = $($(cm.getByAttr('name', 'general[view]').item(0))).val(); 7770 if (test) 7771 value = test; 7772 } 7773 7774 column.hide(); 7775 rows.hide(); 7776 paginator.hide(); 7777 style.hide(); 7778 caption.hide(); 7779 7780 $(preview).empty(); 7781 switch (value) { 7782 case 'slider': 7783 style.show(); 7784 Com.GetSelect('videogallery-style').triggerEvent('onChange'); 7785 break; 7786 case 'grid': 7787 column.show(); 7788 rows.show(); 7789 paginator.show(); 7790 caption.show(); 7791 Com.GetSelect('videogallery-column').triggerEvent('onChange'); 7792 break; 7793 } 7794 ; 7795 }); 7796 7797 setTimeout(function () { 7798 view.triggerEvent('onChange'); 7799 }, 1000); 7800 } 7801 } else if (node.name == 'type') { 7802 var setSpecify = function (value) { 7803 if (value) { 7804 var specify = Com.GetSelect('video_specify'); 7805 if (specify) { 7806 if (specify.getOptionsAll()) { 7807 specify.removeOptionsAll(); 7808 } 7809 var data = cm.getEl('video_specify').getAttribute('data-' + value); 7810 data = JSON.parse(data)[0]; 7811 cm.forEach(data, function (item, key) { 7812 specify.addOption(key, item); 7813 }); 7814 specify.set(specify.getOptionsAll()[0].value); 7815 } 7816 } 7817 return 0; 7818 } 7819 7820 var type = Com.GetSelect('video_type'); 7821 if (type) { 7822 type.addEvent('onChange', function (element, value) { 7823 setSpecify(value); 7824 }); 7825 setSpecify(type.get()); 7826 } 7827 } 7828 }); 7829 7830 Collector.add('module_video-gallery', function (node) { 7831 new App.ModuleImageGallery({'node' : node}); 7832 }); 7833 7834 Collector.add('form_video-gallery_add', function (node) { 7835 new App.FormVideoGallery({'node' : node}); 7836 }); 7837 7838}(window.jQuery); 7839 7840 7841 7842!(function() { 7843 Collector.add('mailchimp-unveil', function (node) { 7844 var hide = function (checked) { 7845 var element = cm.getNodes().App.MailChimp.list; 7846 if (checked) { 7847 cm.removeClass(element, 'display-none'); 7848 } else { 7849 cm.addClass(element, 'display-none'); 7850 } 7851 }; 7852 7853 cm.addEvent(node, 'click', function (e) { 7854 hide(node.checked); 7855 }); 7856 7857 hide(node.checked); 7858 }); 7859})(); 7860 7861 7862
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.