1(function($) { 2 Drupal.behaviors.panopolyImagesModule = { 3 attach: function (context, settings) { 4 var captions = $('.caption', context).has('img'); 5 $(captions).once('panopoly-images').imagesLoaded(function () { 6 panopolyImagesResizeCaptionBox(captions); 7 }); 8 9 function panopolyImagesResizeCaptionBox(captions) { 10 captions.each(function() { 11 var imageSet = $('img', this), 12 imgBoxWidth = getImgWidth(imageSet), 13 wrapperBoxWidth = 14 getWrapperSpacing($('.caption-inner', this)) 15 + getWrapperSpacing($('.caption-width-container', this)), 16 totalWidth = imgBoxWidth + wrapperBoxWidth; 17 $(this).width(totalWidth); 18 }); 19 } 20 21 // Get width of image plus margins, borders and padding 22 function getImgWidth(imageSet) { 23 var imgWidth = 0, 24 imgBoxExtra = 0, 25 testWidth = 0; 26 var attrWidth; 27 28 // We shouldn't have more than one image in a caption, but it would be 29 // possible, so we make sure we have the widest one 30 for (var i = 0; i < imageSet.length; i++) { 31 // If we have a hardcoded width attribute from manual resizing in 32 // TinMCE, use that. If not, use the image naturalWidth. We can't 33 // reliably use width() for responsive images. 34 attrWidth = $(imageSet[i]).attr("width"); 35 if (typeof attrWidth !== 'undefined') { 36 // attr() returns a string. Must convert to int for math to work. 37 testWidth = parseInt(attrWidth, 10); 38 } 39 else { 40 testWidth = imageSet[i].naturalWidth; 41 } 42 if (testWidth > imgWidth) { 43 imgWidth = testWidth; 44 imgBoxExtra = getWrapperSpacing(imageSet[i]) 45 } 46 } 47 return imgWidth + imgBoxExtra; 48 } 49 50 // We want the total of margin, border and padding on the element 51 function getWrapperSpacing(el) { 52 var spacing = ['margin-left', 'border-left', 'padding-left', 'padding-right', 'border-right', 'margin-right'], 53 totalPx = 0, 54 spacePx = 0, 55 spaceRaw = ''; 56 for (var i = 0; i < spacing.length; i++) { 57 spaceRaw = $(el).css(spacing[i]); 58 59 // Themers might add padding, borders or margin defined in ems, but we can't 60 // add that to pixel dimensions returned by naturalWidth, so we just throw 61 // away anything but pixels. Themers have to deal with that. 62 if(spaceRaw && spaceRaw.substr(spaceRaw.length - 2) == 'px') { 63 spacePx = parseInt(spaceRaw, 10); 64 totalPx += ($.isNumeric(spacePx)) ? spacePx : 0; 65 } 66 } 67 return totalPx; 68 } 69 } 70 } 71})(jQuery); 72; 73(function ($) { 74/** 75 * Media Colorbox behavior. 76 */ 77Drupal.behaviors.initMediaColorbox = { 78 attach: function (context, settings) { 79 if (!$.isFunction($.colorbox)) { 80 console.log('You must install the Colorbox library.'); 81 return; 82 } 83 var enableAudioPlaylist = false; 84 85 $('a.media-colorbox', context).once('init-media-colorbox', function() { 86 87 // Merge Colorbox settings with Media Colorbox settings from data attributes. 88 var options = jQuery.extend({}, settings.colorbox); 89 var mediaColorboxSettings = {}; 90 if($(this).data('mediaColorboxFixedWidth') > 0) { 91 mediaColorboxSettings = {width: $(this).data('mediaColorboxFixedWidth')}; 92 jQuery.extend(options, mediaColorboxSettings); 93 } 94 if($(this).data('mediaColorboxFixedHeight') > 0){ 95 mediaColorboxSettings = {height: $(this).data('mediaColorboxFixedHeight')}; 96 jQuery.extend(options, mediaColorboxSettings); 97 } 98 99 // Set up the callback and listener to go to to next slide 100 $(this).colorbox(options); 101 if($(this).data('mediaColorboxAudioPlaylist')){ 102 enableAudioPlaylist = true; 103 } 104 }); 105 106 // Set up the callback and listener to go to to next slide 107 $(document).bind('cbox_complete', function() { 108 if(enableAudioPlaylist) { 109 $("audio").bind("ended", function(event) { 110 setTimeout($.colorbox.next, 100); 111 }); 112 } 113 $("#cboxLoadedContent img").bind("click", function (event) { 114 setTimeout($.colorbox.next, 0); 115 }); 116 $("#cboxLoadedContent img").css('cursor', 'pointer'); 117 }); 118 } 119}; 120})(jQuery); 121; 122(function ($) { 123 124/** 125 * Adds Organic Groups GET variables to jQuery Ajax request URLs. 126 */ 127Drupal.behaviors.ogContext = { 128 attach: function (context, settings) { 129 if (Drupal.settings.ogContext) { 130 // The only reliable way to modify an Ajax request to add GET variables 131 // seems to be to override the jQuery.ajax() function entirely. See 132 // https://stackoverflow.com/questions/2332305/modifying-a-jquery-ajax-request-intercepted-via-ajaxsen
132d 133 var jQueryAjax = $.ajax; 134 $.ajax = function (settings_or_url, settings) { 135 // jQuery allows this function to be called as either $.ajax(settings) 136 // or $.ajax(url, settings), so handle both cases here. 137 if (typeof settings_or_url === 'string') { 138 if (typeof settings === 'undefined') { 139 settings = {}; 140 } 141 settings.url = settings_or_url; 142 } 143 else { 144 settings = settings_or_url; 145 } 146 147 // Modify the Ajax request URL to add the GET variable, but only if the 148 // request is being made to a URL on this site. 149 if (typeof settings.url !== 'undefined' && Drupal.urlIsLocal(settings.url)) { 150 settings.url += settings.url.indexOf('?') >= 0 ? '&' : '?'; 151 settings.url += 'og_ajax_context__gid=' + Drupal.settings.ogContext.gid + '&og_ajax_context__group_type=' + Drupal.settings.ogContext.groupType; 152 } 153 154 return jQueryAjax(settings); 155 }; 156 } 157 } 158}; 159 160})(jQuery); 161; 162(function ($) { 163 164 /** 165 * UI Improvements for the Content Editing Form 166 */ 167 Drupal.behaviors.panopolyAdmin = { 168 attach: function (context, settings) { 169 // Make the permalink field full width. 170 var width = $('#node-edit #edit-title').width() - $('#node-edit .form-item-path-alias label').width() - $('#node-edit .form-item-path-alias .field-prefix').width() - 10; 171 $('#node-edit .form-item-path-alias input').css('width', width); 172 173 // Hide the body label in Javascript if requested, which allows the summary 174 // Javacript to continue working. 175 $('#node-edit .panopoly-admin-hide-body-label .form-item-body-und-0-value label', context) 176 .once('panopoly-admin-hide-body-label') 177 .wrapInner('<span class="element-invisible"></span>') 178 .css('text-align', 'right'); 179 180 if ($('#node-edit .form-item-field-featured-image-und-0-alt label')) { 181 $('#node-edit .form-item-field-featured-image-und-0-alt label').html('Alt Text'); 182 } 183 } 184 } 185 186 /** 187 * Automatically Upload Files/Images Attached 188 */ 189 Drupal.behaviors.panopolyAutoUpload = { 190 attach: function (context, settings) { 191 $('#node-edit input#edit-field-featured-image-und-0-upload').next('input[type="submit"]').hide(); 192 $('form', context).delegate('#node-edit input#edit-field-featured-image-und-0-upload', 'change', function() { 193 $(this).next('input[type="submit"]').mousedown(); 194 }); 195 } 196 }; 197 198 /** 199 * Automatically fill in a menu link title, if possible. 200 * 201 * NOTE: This behavior is a copy and paste from the Core Menu module's menu.js 202 * script. It has been adapted to update proper targeting. This brings back 203 * the core functionality. 204 */ 205 Drupal.behaviors.panopolyLinkAutomaticTitle = { 206 attach: function (context) { 207 $('.pane-node-form-menu', context).each(function () { 208 // Try to find menu settings widget elements as well as a 'title' field in 209 // the form, but play nicely with user permissions and form alterations. 210 var $checkbox = $('.form-item-menu-enabled input', this); 211 var $link_title = $('.form-item-menu-link-title input', context); 212 var $title = $(this).closest('form').find('.form-item-title input'); 213 // Bail out if we do not have all required fields. 214 if (!($checkbox.length && $link_title.length && $title.length)) { 215 return; 216 } 217 // If there is a link title already, mark it as overridden. The user expects 218 // that toggling the checkbox twice will take over the node's title. 219 if ($checkbox.is(':checked') && $link_title.val().length) { 220 $link_title.data('menuLinkAutomaticTitleOveridden', true); 221 } 222 // Whenever the value is changed manually, disable this behavior. 223 $link_title.keyup(function () { 224 $link_title.data('menuLinkAutomaticTitleOveridden', true); 225 }); 226 // Global trigger on checkbox (do not fill-in a value when disabled). 227 $checkbox.change(function () { 228 if ($checkbox.is(':checked')) { 229 if (!$link_title.data('menuLinkAutomaticTitleOveridden')) { 230 $link_title.val($title.val()); 231 } 232 } 233 else { 234 $link_title.val(''); 235 $link_title.removeData('menuLinkAutomaticTitleOveridden'); 236 } 237 $checkbox.closest('fieldset.vertical-tabs-pane').trigger('summaryUpdated'); 238 $checkbox.trigger('formUpdated'); 239 }); 240 // Take over any title change. 241 $title.keyup(function () { 242 if (!$link_title.data('menuLinkAutomaticTitleOveridden') && $checkbox.is(':checked')) { 243 $link_title.val($title.val()); 244 $link_title.val($title.val()).trigger('formUpdated'); 245 } 246 }); 247 }); 248 } 249 }; 250 251})(jQuery); 252; 253(function ($) { 254 Drupal.behaviors.panopolyMagic = { 255 attach: function (context, settings) { 256 /** 257 * Title Hax for Panopoly 258 * 259 * Replaces the markup of a node title pane with 260 * the h1.title page element 261 */ 262 if ($.trim($('.pane-node-title .pane-content').html()) == $.trim($('h1.title').html())) { 263 $('.pane-node-title .pane-content').html(''); 264 $('h1.title').hide().clone().prependTo('.pane-node-title .pane-content'); 265 $('.pane-node-title h1.title').show(); 266 } 267 } 268 }; 269})(jQuery); 270 271(function ($) { 272 // Used to only update preview after changes stop for a second. 273 var timer; 274 275 // Used to make sure we don't wrap Drupal.wysiwygAttach() more than once. 276 var wrappedWysiwygAttach = false;
277 278 // Used to make sure we don't wrap insertLink() on the Linkit field helper 279 // more than once. 280 var wrappedLinkitField = false; 281 282 // Triggers the CTools autosubmit on the given form. If timeout is passed, 283 // it'll set a timeout to do the actual submit rather than calling it directly 284 // and return the timer handle. 285 function triggerSubmit(form, timeout) { 286 var $form = $(form), 287 preview_widget = $('#panopoly-form-widget-preview'), 288 submit; 289 if (!preview_widget.hasClass('panopoly-magic-loading')) { 290 preview_widget.addClass('panopoly-magic-loading'); 291 submit = function () { 292 if (document.contains(form)) { 293 $form.find('.ctools-auto-submit-click').click(); 294 } 295 }; 296 if (typeof timeout === 'number') { 297 return setTimeout(submit, timeout); 298 } 299 else { 300 submit(); 301 } 302 } 303 } 304 305 // Used to cancel a submit. It'll clear the timer and the class marking the 306 // loading operation. 307 function cancelSubmit(form, timer) { 308 var $form = $(form), 309 preview_widget = $('#panopoly-form-widget-preview'); 310 preview_widget.removeClass('panopoly-magic-loading'); 311 clearTimeout(timer); 312 } 313 314 function onWysiwygChangeFactory(editorId) { 315 return function () { 316 var textarea = $('#' + editorId), 317 form = textarea.get(0).form; 318 319 if (textarea.hasClass('panopoly-textarea-autosubmit')) { 320 // Wait a second and then submit. 321 cancelSubmit(form, timer); 322 timer = triggerSubmit(form, 1000); 323 } 324 }; 325 } 326 327 // A function to run before Drupal.wysiwyg.editor.attach.tinymce() with the 328 // same arguments. 329 function wysiwygTinymceBeforeAttach(context, params, settings) { 330 var onWysiwygChange = onWysiwygChangeFactory(params.field), 331 textarea = $('#' + params.field); 332 if (textarea.hasClass('panopoly-textarea-autosubmit')) { 333 settings['setup'] = function (editor) { 334 editor.onChange.add(onWysiwygChange); 335 editor.onKeyUp.add(onWysiwygChange); 336 }; 337 } 338 } 339 340 // A function to run before Drupal.wysiwyg.editor.attach.markitup() with the 341 // same arguments. 342 function wysiwygMarkitupBeforeAttach(context, params, settings) { 343 var onWysiwygChange = onWysiwygChangeFactory(params.field); 344 $.each(['afterInsert', 'onEnter'], function (index, funcName) { 345 settings[funcName] = onWysiwygChange; 346 }); 347 } 348 349 // Used to wrap a function with a beforeFunc (we use it for wrapping 350 // Drupal.wysiwygAttach()). 351 function wrapFunctionBefore(parent, name, beforeFunc) { 352 var originalFunc = parent[name]; 353 parent[name] = function () { 354 beforeFunc.apply(this, arguments); 355 return originalFunc.apply(this, arguments); 356 }; 357 } 358 359 // Used to wrap a function with an afterFunc (we use it for wrapping 360 // insertLink() on the Linkit field helper); 361 function wrapFunctionAfter(parent, name, afterFunc) { 362 var originalFunc = parent[name]; 363 parent[name] = function () { 364 var retval = originalFunc.apply(this, arguments); 365 afterFunc.apply(this, arguments); 366 return retval; 367 }; 368 } 369 370 /** 371 * Improves the Auto Submit Experience for CTools Modals 372 */ 373 Drupal.behaviors.panopolyMagicAutosubmit = { 374 attach: function (context, settings) { 375 // Move focus to preview after it's shown. 376 $('body').once(function () { 377 if (typeof Drupal.CTools !== 'undefined' && typeof Drupal.CTools.Modal !== 'undefined' && typeof Drupal.CTools.Modal.modal_display) { 378 var modal_display = Drupal.CTools.Modal.modal_display; 379 Drupal.CTools.Modal.modal_display = function (ajax, response, status) { 380 var url = ajax.url, 381 params = {}, 382 widget_name; 383 384 // Do the parent operation. 385 modal_display(ajax, response, status); 386 387 // Parse the GET arguments. 388 url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str, key, value) { 389 params[key] = value; 390 }) 391 if (params['panopoly_magic_preview'] == 'manual') { 392 widget_name = decodeURIComponent(params['preview_panes']).split(',').pop(); 393 widget_name.replace(':', '-'); 394 widget_name.replace(/[^a-zA-Z0-9_]/g, ''); 395 // Need to defer until current set of behaviors is done, because Panels 396 // will move the focus to the first widget by default. 397 setTimeout(function () {
398 $('#modal-content .panopoly-magic-preview-' + widget_name + ' :focusable:first').focus(); 399 }, 0); 400 } 401 else if (params['panopoly_magic_preview'] == 'single') { 402 // Ditto. 403 setTimeout(function () { 404 $('#modal-content .panopoly-magic-preview :focusable:first').focus(); 405 }, 0); 406 } 407 }; 408 } 409 }); 410 411 // Replaces click with mousedown for submit so both normal and ajax work. 412 $('.ctools-auto-submit-click', context) 413 .click(function(event) { 414 if ($(this).hasClass('ajax-processed')) { 415 event.stopImmediatePropagation(); 416 $(this).trigger('mousedown'); 417 return false; 418 } 419 }); 420 421 // e.keyCode: key 422 var discardKeyCode = [ 423 16, // shift 424 17, // ctrl 425 18, // alt 426 20, // caps lock 427 33, // page up 428 34, // page down 429 35, // end 430 36, // home 431 37, // left arrow 432 38, // up arrow 433 39, // right arrow 434 40, // down arrow 435 9, // tab 436 13, // enter 437 27 // esc 438 ]; 439 440 // Special handling for link field widgets. This ensures content which is ahah'd in still properly autosubmits. 441 $('.field-widget-link-field input:text', context).addClass('panopoly-textfield-autosubmit').addClass('ctools-auto-submit-exclude'); 442 443 // Handle text fields and textareas. 444 $('.panopoly-textfield-autosubmit, .panopoly-textarea-autosubmit', context) 445 .once('ctools-auto-submit') 446 .bind('keyup blur', function (e) { 447 var $element; 448 $element = $('.panopoly-magic-preview .pane-title', context); 449 450 cancelSubmit(e.target.form, timer); 451 452 // Filter out discarded keys. 453 if (e.type !== 'blur' && $.inArray(e.keyCode, discardKeyCode) > 0) { 454 return; 455 } 456 457 // Set a timer to submit the form a second after the last activity. 458 timer = triggerSubmit(e.target.form, 1000); 459 }); 460 461 // Handle WYSIWYG fields. 462 if (!wrappedWysiwygAttach && typeof Drupal.wysiwyg != 'undefined' && typeof Drupal.wysiwyg.editor.attach.tinymce == 'function' && typeof Drupal.wysiwyg.editor.attach.markitup == 'function') { 463 wrapFunctionBefore(Drupal.wysiwyg.editor.attach, 'tinymce', wysiwygTinymceBeforeAttach); 464 //wrapFunctionBefore(Drupal.wysiwyg.editor.attach, 'markitup', wysiwygMarkitupBeforeAttach); 465 wrappedWysiwygAttach = true; 466 467 // Since the Drupal.behaviors run in a non-deterministic order, we can 468 // never be sure that we wrapped Drupal.wysiwygAttach() before it was 469 // used! So, we look for already attached editors so we can detach and 470 // re-attach them. 471 $('.panopoly-textarea-autosubmit', context) 472 .once('panopoly-magic-wysiwyg') 473 .each(function () { 474 var editorId = this.id, 475 instance = Drupal.wysiwyg.instances[editorId], 476 format = instance ? instance.format : null, 477 trigger = instance ? instance.trigger : null; 478 479 if (instance && instance.editor != 'none') { 480 params = Drupal.settings.wysiwyg.triggers[trigger]; 481 if (params) { 482 Drupal.wysiwygDetach(context, params[format]); 483 Drupal.wysiwygAttach(context, params[format]); 484 } 485 } 486 }); 487 } 488 489 // Handle autocomplete fields. 490 $('.panopoly-autocomplete-autosubmit', context) 491 .once('ctools-auto-submit') 492 .bind('keyup blur', function (e) { 493 // Detect when a value is selected via TAB or ENTER. 494 if (e.type === 'blur' || e.keyCode === 13) { 495 // We defer the submit call so that it happens after autocomplete has 496 // had a chance to fill the input with the selected value. 497 triggerSubmit(e.target.form, 0); 498 } 499 }); 500 501 // Prevent ctools auto-submit from firing when changing text formats. 502 $(':input.filter-list').addClass('ctools-auto-submit-exclude'); 503 504 // Handle Linkit fields. 505 if (!wrappedLinkitField && typeof Drupal.linkit !== 'undefined') { 506 var linkitFieldHelper = Drupal.linkit.getDialogHelper('field'); 507 if (typeof linkitFieldHelper !== 'undefined') { 508 wrapFunctionAfter(linkitFieldHelper, 'insertLink', function (data) { 509 var element = document.getElementById(Drupal.settings.linkit.currentInstance.source); 510 triggerSubmit(element.form); 511 }); 512 wrappedLinkitField = true; 513 } 514 } 515 516 } 517 } 518})(jQuery); 519; 520(function ($) { 521 522 Drupal.behaviors.PanelsAccordionStyle = { 523 attach: function (context, settings) { 524 for (region_id in Drupal.settings.accordion) { 525 var accordion = Drupal.settings.accordion[region_id]; 526 if (jQuery('#'+region_id).hasClass("ui-accordion")) { 527 jQuery('#'+region_id).accordion("refresh"); 528 } else { 529 jQuery('#'+region_id).accordion(accordion.options); 530 } 531 } 532 } 533 }; 534 535})(jQuery); 536; 537/** 538 * @file 539 * JavaScript integrations between the Caption Filter module and particular 540 * WYSIWYG editors. This file also implements Insert module hooks to respond 541 * to the insertion of content into a WYSIWYG or textarea. 542 */ 543(function ($) { 544 545$(document).bind('insertIntoActiveEditor', function(event, options) { 546 if (options['fields']['title'] && Drupal.settings.captionFilter.widgets[options['widgetType']]) { 547 options['content'] = '[caption caption="' + options['fields']['title'].replace(/"/g, '\\"') + '"]' + options['content'] + '[/caption]'; 548 } 549}); 550 551Drupal.captionFilter = Drupal.captionFilter || {}; 552 553Drupal.captionFilter.toHTML = function(co, editor) { 554 return co.replace(/(?:<p>)?\[caption([^\]]*)\]([\s\S]+?)\[\/caption\](?:<\/p>)?[\s\u00a0]*/g, function(a,b,c){ 555 var id, cls, w, tempClass; 556 557 b = b.replace(/\\?'|\\'|\\'/g, ''').replace(/\\"|\\"/g, '"'); 558 c = c.replace(/\\'|\\'/g, ''').replace(/\\"/g, '"'); 559 id = b.match(/id=['"]([^'"]+)/i); 560 cls = b.match(/align=['"]([^'"]+)/i); 561 ct = b.match(/caption=['"]([^'"]+)/i); 562 w = c.match(/width=['"]([0-9]+)/); 563 564 id = ( id && id[1] ) ? id[1] : '';
565 cls = ( cls && cls[1] ) ? 'caption-' + cls[1] : ''; 566 ct = ( ct && ct[1] ) ? ct[1].replace(/\\\\"/,'"') : ''; 567 w = ( w && w[1] ) ? parseInt(w[1])+'px' : 'auto'; 568 569 if (editor == 'tinymce') 570 tempClass = (cls == 'caption-center') ? 'mceTemp mceIEcenter' : 'mceTemp'; 571 else if (editor == 'ckeditor') 572 tempClass = (cls == 'caption-center') ? 'mceTemp mceIEcenter' : 'mceTemp'; 573 else 574 tempClass = ''; 575 576 if (ct) { 577 return '<div class="caption ' + cls + ' ' + tempClass + ' draggable"><div class="caption-width-container" style="width: ' + w + '"><div class="caption-inner">' + c + '<p class="caption-text">' + ct + '</p></div></div></div><br />'; 578 } 579 else { 580 return '<div class="caption ' + cls + ' ' + tempClass + ' draggable"><div class="caption-width-container" style="width: ' + w + '"><div class="caption-inner">' + c + '</div></div></div><br />'; 581 } 582 }); 583}; 584 585Drupal.captionFilter.toTag = function(co) { 586 return co.replace(/(<div class="caption [^"]*">)\s*<div[^>]+>\s*<div[^>]+>(.+?)<\/div>\s*<\/div>\s*<\/div>\s*/gi, function(match, captionWrapper, contents) { 587 var align; 588 align = captionWrapper.match(/class=.*?caption-(left|center|right)/i); 589 align = (align && align[1]) ? align[1] : ''; 590 caption = contents.match(/\<p class=\"caption-text\"\>(.*)\<\/p\>/); 591 caption_html = (caption && caption[0]) ? caption[0] : ''; 592 caption = (caption && caption[1]) ? caption[1].replace(/"/g, '\\"') : ''; 593 contents = contents.replace(caption_html, ''); 594 595 return '[caption' + (caption ? (' caption="' + caption + '"') : '') + (align ? (' align="' + align + '"') : '') + ']' + contents + '[/caption]'; 596 }); 597}; 598 599})(jQuery); 600;
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.