1Drupal.locale = { 'pluralFormula': function ($n) { return Number(($n!=1)); }, 'strings': {"":{"Show row weights":"Exibir pesos das linhas","The block cannot be placed in this region.":"O bloco n\u00e3o pode ser colocado nessa regi\u00e3o.","No results":"Nenhum resultado","Scheduled for publishing":"Agendado para publica\u00e7\u00e3o","Publishing enabled":"Publica\u00e7\u00e3o habilitada","Scheduled for unpublishing":"Agendado para despublica\u00e7\u00e3o","Add files":"Adicionar arquivos","Add files to the upload queue and click the start button.":"Adicione arquivos \u00e0 fila de upload e clique no bot\u00e3o Iniciar.","Start uploading queue":"Inicie a fila de upload","Uploaded %d\/%d files":"Arquivos %d\/%d enviados","Don\u0027t display post information":"N\u00e3o exibir informa\u00e7\u00f5es de postagem","Requires a title":"T\u00edtulo requerido","Done":"Conclu\u00eddo","An AJAX HTTP error occurred.":"Ocorreu um erro HTTP no AJAX","Debugging information follows.":"Estas s\u00e3o as informa\u00e7\u00f5es de depura\u00e7\u00e3o.","ResponseText: !responseText":"Texto de Resposta: !responseText","Prev":"Anterior","First click a text field to insert your tokens into.":"Primeiramente, clique no campo de texto para inserir seus tokens nela","September":"setembro","mm\/dd\/yy":"mm\/dd\/yy","We":"Qua","April":"abril","November":"novembro","October":"outubro","By @name on @date":"Por @name em @date","Edit summary":"Editar resumo","Please wait...":"Por favor, aguarde...","Fr":"Sex","Su":"Dom","@label: @value":"@label: @value","Using defaults":"Utilizar padr\u00f5es","March":"mar\u00e7o","December":"dezembro","Tu":"Ter","Deselect all rows in this table":"Desmarcar todas as linhas da tabela","Apply (all displays)":"Aplicar (em todos os displays)","Apply (this display)":"Aplicar (neste display)","Apr":"abr","An AJAX HTTP request terminated abnormally.":"Uma requisi\u00e7\u00e3o HTTP AJAX terminou de forma inesperada.","Not restricted":"Sem restri\u00e7\u00f5es","Loading token browser...":"Carregando o navegador do token...","Friday":"sexta-feira","No revision":"Sem revis\u00e3o","Hide shortcuts":"Esconder atalhos","This will discard all unsaved changes. Are you sure?":"Isto ir\u00e1 descartar todas as mudan\u00e7as n\u00e3o salvas. Tem certeza?","Unpublishing enabled":"Despublica\u00e7\u00e3o habilitada","By @name":"Por @name","Mo":"Seg","Autocomplete popup":"Popup de autocompletar","Blank":"Vazio","Searching for matches...":"Procurando por dados correspondentes...","Hide summary":"Ocultar sum\u00e1rio","Select all rows in this table":"Selecionar todas as linhas da tabela","Insert this token into your form":"Insira este token no seu formul\u00e1rio","This permission is inherited from the authenticated user role.":"Essa permiss\u00e3o \u00e9 herdada do papel de usu\u00e1rio autenticado.","Drag to re-order":"Arraste para reordenar","@enabled of @total":"@enabled de @total","Error: File too large: ":"Erro: arquivo muito grande:","Filename":"Nome do arquivo","Jul":"jul","StatusText: !statusText":"Texto de Status: !statusText","N\/A":"-","HTTP Result Code: !status":"C\u00f3digo do Resultado HTTP: !status","Path: !uri":"Caminho: !uri","ReadyState: !readyState":"ReadyState: !readyState","Re-order rows by numerical weight instead of dragging.":"Re-ordernar as linhas por campos n\u00famericos de peso ao inv\u00e9s de arrastar-e-soltar.","Hide row weights":"Ocultar pesos das linhas","Changes made in this table will not be saved until the form is submitted.":"As mudan\u00e7as feitas nesta tabela n\u00e3o v\u00e3o ser salvas antes do formul\u00e1rio ser enviado.","Restricted to certain pages":"Restrito para certas p\u00e1ginas","Monday":"segunda-feira","Search":"Buscar","Deselect all":"Desmarcar todos","Today":"Hoje","February":"fevereiro","The selected file %filename cannot be uploaded. Only files with the following extensions are allowed: %extensions.":"O arquivo selecionado %filename n\u00e3o p\u00f4de ser transferido. Somente arquivos com as seguintes extens\u00f5es s\u00e3o permitidos: %extensions.","Alias: @alias":"URL Alternativa: @alias","Inverse":"Invertido","Configure":"Configurar","Saturday":"s\u00e1bado","Next":"Pr\u00f3ximo","View":"Ver","Sun":"dom","Other":"Outros","(active tab)":"(aba ativa)","Thursday":"quinta-feira","Add":"Adicionar","Breadcrumbs":"Breadcrumbs","Jan":"jan","Select all":"Selecionar Tudo","Sep":"set","Nov":"nov","Tuesday":"ter\u00e7a-feira","Hide":"Ocultar","Fri":"sex","Thu":"qui","Wed":"qua","Mon":"seg","Show":"Exibir","Operation":"Opera\u00e7\u00e3o","Link Target":"Destino do Link","Disabled":"Desativado","All":"Tudo","Published":"Publicado","Status":"Status","Size":"Tamanho","Wednesday":"quarta-feira","Jun":"jun","Aug":"ago","Mar":"mar","May":"mai","Oct":"out","Show shortcuts":"Mostrar atalhos","Revert to default":"Reverter ao padr\u00e3o","Not customizable":"N\u00e3o \u00e9 personaliz\u
100e1vel","Start upload":"Iniciar o envio","Content limited to @limit characters, remaining: \u003Cstrong\u003E@remaining\u003C\/strong\u003E":"Conte\u00fado limitado \u00e0 @limit caracteres, remanescente: \u003Cstrong\u003E@remaining\u003C\/strong\u003E","Drop a resource from Scald media library here.":"Solte um recurso da biblioteca de m\u00eddia Scald aqui","Show description":"Mostrar descri\u00e7\u00e3o","The changes to these blocks will not be saved until the \u003Cem\u003ESave blocks\u003C\/em\u003E button is clicked.":"As altera\u00e7\u00f5es nesses blocos n\u00e3o v\u00e3o ser salvas enquanto o bot\u00e3o \u003Cem\u003ESalvar Blocos\u003C\/em\u003E n\u00e3o for clicado.","Hide description":"Ocultar descri\u00e7\u00e3o","Not scheduled":"N\u00e3o agendado","Query":"Consulta","Drag files here.":"Arraste os arquivos aqui.","Edit":"Editar","Remove":"Remover","No alias":"Nenhuma URL alternativa","None":"Nenhum","Link":"Link","Enabled":"Habilitado","Sunday":"domingo","Translatable":"Traduz\u00edvel","Th":"Qui","Dec":"dez","January":"janeiro","Sa":"S\u00e1b","Available tokens":"Tokens dispon\u00edveis","August":"agosto","June":"junho","July":"julho","Remove group":"Remover grupo","Recent":"Recente","New":"Novo","Automatic alias":"Endere\u00e7o autom\u00e1tico","Not published":"N\u00e3o publicado","Parent":"Superior","Tue":"ter","Sat":"sab","New revision":"Nova revis\u00e3o"}} };; 2/** 3 * @file 4 * Lazyloader echo integration. 5 */ 6 7(function($){ 8 // Cache the icon and it's dimensions. 9 var lazyloader_icon; 10 11 Drupal.behaviors.lazyloader = { 12 attach: function (context, settings) { 13 if (lazyloader_icon == undefined) { 14 lazyloader_icon = new Image(); 15 16 $(lazyloader_icon).attr({src: settings.lazyloader.icon}).addClass('lazyloader-icon'); 17 } 18 19 // add the loader icon 20 if(settings.lazyloader.icon != '') { 21 $('img[data-echo]').each(function() { 22 var $img = $(this); 23 var $icon = $(lazyloader_icon).clone(); 24 $icon.css({ 25 position: 'relative', 26 top: '-' + Math.floor($img.height() / 2 - settings.lazyloader.offsetY) + 'px', 27 left: '-'+ Math.floor($img.width() / 2 + settings.lazyloader.offsetX) + 'px', 28 }); 29 $($icon).insertAfter($img); 30 }); 31 } 32 33 // Initialize echo. 34 echo.init({ 35 offset: settings.lazyloader.offset, 36 throttle: settings.lazyloader.throttle, 37 unload: settings.lazyloader.unload, 38 debounce: settings.lazyloader.debounce, 39 callback: function (element, op) { 40 // Remove the loader icon when the image is loaded. 41 $(element).next('.lazyloader-icon').remove(); 42 } 43 }); 44 45 // Add a scroll eventlistener to every parent element with overflow:scroll; so we can trigger echo when the 46 // element is scrolled. 47 $('img[data-echo], [data-echo-background]').each(function() { 48 $(this).parents().each(function() { 49 if ($(this).css('overflow') == 'scroll') { 50 $(this).bind('scroll', function() { 51 lazyloaderDebounceOrThrottle(settings.lazyloader.debounce, settings.lazyloader.throttle) 52 }); 53 } 54 }); 55 }); 56 }, 57 58 detach: function (context, settings) { 59 // Detach echo. 60 echo.detach(); 61 }, 62 63 // Variable for throttling. 64 poll: null 65 }; 66 67})(jQuery); 68 69function lazyloaderDebounceOrThrottle(debounce, throttle) { 70 if(!debounce && !!Drupal.behaviors.lazyloader.poll) { 71 return; 72 } 73 clearTimeout(Drupal.behaviors.lazyloader.poll); 74 Drupal.behaviors.lazyloader.poll = setTimeout(function(){ 75 echo.render(); 76 Drupal.behaviors.lazyloader.poll = null; 77 }, throttle); 78}; 79/*! echo-js v1.7.3 | (c) 2016 @toddmotto | https://github.com/toddmotto/echo */ 80!function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):"object"==typeof exports?module.exports=e:t.echo=e(t)}(this,function(t){"use strict";var e,n,o,r,c,a={},u=function(){},d=function(t){return null===t.offsetParent},i=function(t,e){if(d(t))return!1;var n=t.getBoundingClientRect();return n.right>=e.l&&n.bottom>=e.t&&n.left<=e.r&&n.top<=e.b},l=function(){(r||!n)&&(clearTimeout(n),n=setTimeout(function(){a.render(),n=null},o))};return a.init=function(n){n=n||{};var d=n.offset||0,i=n.offsetVertical||d,f=n.offsetHorizontal||d,s=function(t,e){return parseInt(t||e,10)};e={t:s(n.offsetTop,i),b:s(n.offsetBottom,i),l:s(n.offsetLeft,f),r:s(n.offsetRight,f)},o=s(n.throttle,250),r=n.debounce!==!1,c=!!n.unload,u=n.callback||u,a.render(),document.addEventListener?(t.addEventListener("scroll",l,!1),t.addEventListener("load",l,!1)):(t.attachEvent("onscroll",l),t.attachEvent("onload",l))},a.render=function(){for(var n,o,r=document.querySelectorAll("img[data-echo], [data-echo-background]"),d=r.length,l={l:0-e.l,t:0-e.t,b:(t.innerHe
80ight||document.documentElement.clientHeight)+e.b,r:(t.innerWidth||document.documentElement.clientWidth)+e.r},f=0;d>f;f++)o=r[f],i(o,l)?(c&&o.setAttribute("data-echo-placeholder",o.src),null!==o.getAttribute("data-echo-background")?o.style.backgroundImage="url("+o.getAttribute("data-echo-background")+")":o.src=o.getAttribute("data-echo"),c||(o.removeAttribute("data-echo"),o.removeAttribute("data-echo-background")),u(o,"load")):c&&(n=o.getAttribute("data-echo-placeholder"))&&(null!==o.getAttribute("data-echo-background")?o.style.backgroundImage="url("+n+")":o.src=n,o.removeAttribute("data-echo-placeholder"),u(o,"unload"));d||a.detach()},a.detach=function(){document.removeEventListener?t.removeEventListener("scroll",l):t.detachEvent("onscroll",l),clearTimeout(n)},a});; 81/** 82 * @file views_load_more.js 83 * 84 * Handles the AJAX pager for the view_load_more plugin. 85 */ 86(function ($) { 87 88 /** 89 * Provide a series of commands that the server can request the client perform. 90 */ 91 Drupal.ajax.prototype.commands.viewsLoadMoreAppend = function (ajax, response, status) { 92 // Get information from the response. If it is not there, default to 93 // our presets. 94 var wrapper = response.selector ? $(response.selector) : $(ajax.wrapper); 95 var method = response.method || ajax.method; 96 var targetList = response.targetList || ''; 97 var effect = ajax.getEffect(response); 98 var pager_selector = response.options.pager_selector ? response.options.pager_selector : '.pager-load-more'; 99 100 // We don't know what response.data contains: it might be a string of text 101 // without HTML, so don't rely on jQuery correctly iterpreting 102 // $(response.data) as new HTML rather than a CSS selector. Also, if 103 // response.data contains top-level text nodes, they get lost with either 104 // $(response.data) or $('<div></div>').replaceWith(response.data). 105 var new_content_wrapped = $('<div></div>').html(response.data); 106 var new_content = new_content_wrapped.contents(); 107 108 // For legacy reasons, the effects processing code assumes that new_content 109 // consists of a single top-level element. Also, it has not been 110 // sufficiently tested whether attachBehaviors() can be successfully called 111 // with a context object that includes top-level text nodes. However, to 112 // give developers full control of the HTML appearing in the page, and to 113 // enable Ajax content to be inserted in places where DIV elements are not 114 // allowed (e.g., within TABLE, TR, and SPAN parents), we check if the new 115 // content satisfies the requirement of a single top-level element, and 116 // only use the container DIV created above when it doesn't. For more 117 // information, please see http://drupal.org/node/736066. 118 if (new_content.length != 1 || new_content.get(0).nodeType != 1) { 119 new_content = new_content_wrapped; 120 } 121 // If removing content from the wrapper, detach behaviors first. 122 var settings = response.settings || ajax.settings || Drupal.settings; 123 Drupal.detachBehaviors(wrapper, settings); 124 if ($.waypoints != undefined) { 125 $.waypoints('refresh'); 126 } 127 128 // Set up our default query options. This is for advance users that might 129 // change there views layout classes. This allows them to write there own 130 // jquery selector to replace the content with. 131 // Provide sensible defaults for unordered list, ordered list and table 132 // view styles. 133 var content_query = targetList && !response.options.content ? '> .view-content ' + targetList : response.options.content || '> .view-content'; 134 135 // If we're using any effects. Hide the new content before adding it to the DOM. 136 if (effect.showEffect != 'show') { 137 new_content.find(content_query).children().hide(); 138 } 139 140 // Update the pager 141 // Find both for the wrapper as the newly loaded content the direct child 142 // .item-list in case of nested pagers 143 wrapper.find(pager_selector).replaceWith(new_content.find(pager_selector)); 144 145 // Add the new content to the page. 146 wrapper.find(content_query)[method](new_content.find(content_query).children()); 147 148 // Re-class the loaded content. 149 // @todo this is faulty in many ways. first of which is that user may have configured view to not have these classes at all. 150 wrapper.find(content_query).children() 151 .removeClass('views-row-first views-row-last views-row-odd views-row-even') 152 .filter(':first') 153 .addClass('views-row-first') 154 .end() 155 .filter(':last') 156 .addClass('views-row-last') 157 .end() 158 .filter(':even') 159 .addClass('views-row-odd') 160 .end() 161 .filter(':odd') 162 .addClass('views-row-even') 163 .end(); 164 165 if (effect.showEffect != 'show') { 166 wrapper.find(content_query).children(':not(:visible)')[effect.showEffect](effect.showSpeed); 167 } 168 169 // Additional processing over new content 170 wrapper.trigger('views_load_more.new_content', new_content.clone()); 171 172 // Attach all JavaScript behaviors to the new content 173 // Remove the Jquery once Class, TODO: There needs to be a better 174 // way of doing this, look at .removeOnce() :-/ 175 var classes = wrapper.attr('class'); 176 var onceClass = classes.match(/jquery-once-[0-9]*-[a-z]*/); 177 wrapper.removeClass(onceClass[0]); 178 settings = response.settings || ajax.settings || Drupal.settings; 179 Drupal.attachBehaviors(wrapper, settings); 180 }; 181 182 /** 183 * Attaches the AJAX behavior to Views Load More waypoint support. 184 */ 185 Drupal.behaviors.ViewsLoadMore = { 186 attach: function (context, settings) { 187 var default_opts = { 188 offset: '100%' 189 }; 190 191 if (settings && settings.viewsLoadMore && settings.views && settings.views.ajaxViews) { 192 $.each(settings.viewsLoadMore, function(i, setting) { 193 var view = '.view-id-' + setting.view_name + '.view-display-id-' + setting.view_display_id + ' .pager-next a', 194 opts = {}; 195 196 $.extend(opts, default_opts, settings.viewsLoadMore[i].opts); 197 198 $(view).waypoint('destroy'); 199 $(view).waypoint(function(event, direction) { 200 $(view).click(); 201 }, opts); 202 }); 203 } 204 }, 205 detach: function (context, settings, trigger) { 206 if (settings && settings.viewsLoadMore && settings.views && settings.views.ajaxViews) { 207 $.each(settings.viewsLoadMore, function(i, setting) { 208 var view = '.view-id-' + setting.view_name + '.view-display-id-' + setting.view_display_id; 209 if ($(context).is(view)) { 210 $('.pager-next a', view).waypoint('destroy'); 211 } 212 else { 213 $(view, context).waypoint('destroy'); 214 } 215 }); 216 } 217 } 218 }; 219})(jQuery); 220; 221/** 222 * @file 223 * Some basic behaviors and utility functions for Views. 224 */ 225(function ($) { 226 227 Drupal.Views = {}; 228 229 /** 230 * JQuery UI tabs, Views integration component. 231 */ 232 Drupal.behaviors.viewsTabs = { 233 attach: function (context) { 234 if ($.viewsUi && $.viewsUi.tabs) { 235 $('#views-tabset').once('views-processed').viewsTabs({ 236 selectedClass: 'active' 237 }); 238 } 239 240 $('a.views-remove-link').once('views-processed').click(function(event) { 241 var id = $(this).attr('id').replace('views-remove-link-', ''); 242 $('#views-row-' + id).hide(); 243 $('#views-removed-' + id).get(0).checked = true; 244 event.preventDefault(); 245 }); 246 // Here is to handle display deletion 247 // (checking in the hidden checkbox and hiding out the row). 248 $('a.display-remove-link') 249 .addClass('display-processed') 250 .click(function() { 251 var id = $(this).attr('id').replace('display-remove-link-', ''); 252 $('#display-row-' + id).hide(); 253 $('#display-removed-' + id).get(0).checked = true; 254 return false;
255 }); 256 } 257 }; 258 259 /** 260 * Helper function to parse a querystring. 261 */ 262 Drupal.Views.parseQueryString = function (query) { 263 var args = {}; 264 var pos = query.indexOf('?'); 265 if (pos != -1) { 266 query = query.substring(pos + 1); 267 } 268 var pairs = query.split('&'); 269 for (var i in pairs) { 270 if (typeof(pairs[i]) == 'string') { 271 var pair = pairs[i].split('='); 272 // Ignore the 'q' path argument, if present. 273 if (pair[0] != 'q' && pair[1]) { 274 args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); 275 } 276 } 277 } 278 return args; 279 }; 280 281 /** 282 * Helper function to return a view's arguments based on a path. 283 */ 284 Drupal.Views.parseViewArgs = function (href, viewPath) { 285 // Provide language prefix. 286 if (Drupal.settings.pathPrefix) { 287 var viewPath = Drupal.settings.pathPrefix + viewPath; 288 } 289 var returnObj = {}; 290 var path = Drupal.Views.getPath(href); 291 // Ensure there is a correct path. 292 if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') { 293 var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length)); 294 returnObj.view_args = args; 295 returnObj.view_path = path; 296 } 297 return returnObj; 298 }; 299 300 /** 301 * Strip off the protocol plus domain from an href. 302 */ 303 Drupal.Views.pathPortion = function (href) { 304 // Remove e.g. http://example.com if present. 305 var protocol = window.location.protocol; 306 if (href.substring(0, protocol.length) == protocol) { 307 // 2 is the length of the '//' that normally follows the protocol. 308 href = href.substring(href.indexOf('/', protocol.length + 2)); 309 } 310 return href; 311 }; 312 313 /** 314 * Return the Drupal path portion of an href. 315 */ 316 Drupal.Views.getPath = function (href) { 317 href = Drupal.Views.pathPortion(href); 318 href = href.substring(Drupal.settings.basePath.length, href.length); 319 // 3 is the length of the '?q=' added to the URL without clean URLs. 320 if (href.substring(0, 3) == '?q=') { 321 href = href.substring(3, href.length); 322 } 323 var chars = ['#', '?', '&']; 324 for (var i in chars) { 325 if (href.indexOf(chars[i]) > -1) { 326 href = href.substr(0, href.indexOf(chars[i])); 327 } 328 } 329 return href; 330 }; 331 332})(jQuery); 333; 334(function ($) { 335 336/** 337 * A progressbar object. Initialized with the given id. Must be inserted into 338 * the DOM afterwards through progressBar.element. 339 * 340 * method is the function which will perform the HTTP request to get the 341 * progress bar state. Either "GET" or "POST". 342 * 343 * e.g. pb = new progressBar('myProgressBar'); 344 * some_element.appendChild(pb.element); 345 */ 346Drupal.progressBar = function (id, updateCallback, method, errorCallback) { 347 var pb = this; 348 this.id = id; 349 this.method = method || 'GET'; 350 this.updateCallback = updateCallback; 351 this.errorCallback = errorCallback; 352 353 // The WAI-ARIA setting aria-live="polite" will announce changes after users 354 // have completed their current activity and not interrupt the screen reader. 355 this.element = $('<div class="progress" aria-live="polite"></div>').attr('id', id); 356 this.element.html('<div class="bar"><div class="filled"></div></div>' + 357 '<div class="percentage"></div>' + 358 '<div class="message"> </div>'); 359}; 360 361/** 362 * Set the percentage and status message for the progressbar. 363 */ 364Drupal.progressBar.prototype.setProgress = function (percentage, message) { 365 if (percentage >= 0 && percentage <= 100) { 366 $('div.filled', this.element).css('width', percentage + '%'); 367 $('div.percentage', this.element).html(percentage + '%'); 368 } 369 $('div.message', this.element).html(message); 370 if (this.updateCallback) { 371 this.updateCallback(percentage, message, this); 372 } 373}; 374 375/** 376 * Start monitoring progress via Ajax. 377 */ 378Drupal.progressBar.prototype.startMonitoring = function (uri, delay) { 379 this.delay = delay; 380 this.uri = uri; 381 this.sendPing(); 382}; 383 384/** 385 * Stop monitoring progress via Ajax. 386 */ 387Drupal.progressBar.prototype.stopMonitoring = function () { 388 clearTimeout(this.timer); 389 // This allows monitoring to be stopped from within the callback. 390 this.uri = null; 391}; 392 393/** 394 * Request progress data from server. 395 */ 396Drupal.progressBar.prototype.sendPing = function () { 397 if (this.timer) { 398 clearTimeout(this.timer); 399 } 400 if (this.uri) { 401 var pb = this; 402 // When doing a post request, you need non-null data. Otherwise a 403 // HTTP 411 or HTTP 406 (with Apache mod_security) error may result. 404 $.ajax({ 405 type: this.method, 406 url: this.uri, 407 data: '', 408 dataType: 'json', 409 success: function (progress) { 410 // Display errors. 411 if (progress.status == 0) { 412 pb.displayError(progress.data); 413 return; 414 } 415 // Update display. 416 pb.setProgress(progress.percentage, progress.message); 417 // Schedule next timer.
418 pb.timer = setTimeout(function () { pb.sendPing(); }, pb.delay); 419 }, 420 error: function (xmlhttp) { 421 pb.displayError(Drupal.ajaxError(xmlhttp, pb.uri)); 422 } 423 }); 424 } 425}; 426 427/** 428 * Display errors on the page. 429 */ 430Drupal.progressBar.prototype.displayError = function (string) { 431 var error = $('<div class="messages error"></div>').html(string); 432 $(this.element).before(error).hide(); 433 434 if (this.errorCallback) { 435 this.errorCallback(this); 436 } 437}; 438 439})(jQuery); 440; 441/** 442 * @file 443 * Handles AJAX fetching of views, including filter submission and response. 444 */ 445(function ($) { 446 447 /** 448 * Attaches the AJAX behavior to exposed filter forms and key views links. 449 */ 450 Drupal.behaviors.ViewsAjaxView = {}; 451 Drupal.behaviors.ViewsAjaxView.attach = function() { 452 if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) { 453 $.each(Drupal.settings.views.ajaxViews, function(i, settings) { 454 Drupal.views.instances[i] = new Drupal.views.ajaxView(settings); 455 }); 456 } 457 }; 458 459 Drupal.views = {}; 460 Drupal.views.instances = {}; 461 462 /** 463 * JavaScript object for a certain view. 464 */ 465 Drupal.views.ajaxView = function(settings) { 466 var selector = '.view-dom-id-' + settings.view_dom_id; 467 this.$view = $(selector); 468 469 // If view is not present return to prevent errors. 470 if (!this.$view.length) { 471 return; 472 } 473 474 // Retrieve the path to use for views' ajax. 475 var ajax_path = Drupal.settings.views.ajax_path; 476 477 // If there are multiple views this might've ended up showing up multiple 478 // times. 479 if (ajax_path.constructor.toString().indexOf("Array") != -1) { 480 ajax_path = ajax_path[0]; 481 } 482 483 // Check if there are any GET parameters to send to views. 484 var queryString = window.location.search || ''; 485 if (queryString !== '') { 486 // Remove the question mark and Drupal path component if any. 487 var queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, ''); 488 if (queryString !== '') { 489 // If there is a '?' in ajax_path, clean url are on and & should be 490 // used to add parameters. 491 queryString = ((/\?/.test(ajax_path)) ? '&' : '?') + queryString; 492 } 493 } 494 495 this.element_settings = { 496 url: ajax_path + queryString, 497 submit: settings, 498 setClick: true, 499 event: 'click', 500 selector: selector, 501 progress: { 502 type: 'throbber' 503 } 504 }; 505 506 this.settings = settings; 507 508 // Add the ajax to exposed forms. 509 this.$exposed_form = $('#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-')); 510 this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this)); 511 512 // Store Drupal.ajax objects here for all pager links. 513 this.links = []; 514 515 // Add the ajax to pagers. 516 this.$view 517 .once(jQuery.proxy(this.attachPagerAjax, this)); 518 519 // Add a trigger to update this view specifically. In order to trigger a 520 // refresh use the following code. 521 // 522 // @code 523 // jQuery('.view-name').trigger('RefreshView'); 524 // @endcode 525 // Add a trigger to update this view specifically. 526 var self_settings = this.element_settings; 527 self_settings.event = 'RefreshView'; 528 var self = this; 529 this.$view.once('refresh', function () { 530 self.refreshViewAjax = new Drupal.ajax(self.selector, self.$view, self_settings); 531 }); 532 }; 533 534 Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() { 535 var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form); 536 button = button[0]; 537 538 // Call the autocomplete submit before doing AJAX. 539 $(button).click(function () { 540 if (Drupal.autocompleteSubmit) { 541 Drupal.autocompleteSubmit(); 542 } 543 }); 544 545 this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings); 546 }; 547 548 /** 549 * Attach the ajax behavior to each link. 550 */ 551 Drupal.views.ajaxView.prototype.attachPagerAjax = function() { 552 this.$view.find('ul.pager > li > a, ol.pager > li > a, th.views-field a, .attachment .views-summary a') 553 .each(jQuery.proxy(this.attachPagerLinkAjax, this)); 554 }; 555 556 /**
557 * Attach the ajax behavior to a single link. 558 */ 559 Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) { 560 var $link = $(link); 561 var viewData = {}; 562 var href = $link.attr('href'); 563 // Don't attach to pagers inside nested views. 564 if ($link.closest('.view')[0] !== this.$view[0] && 565 $link.closest('.view').parent().hasClass('attachment') === false) { 566 return; 567 } 568 569 // Provide a default page if none has been set. This must be done 570 // prior to merging with settings to avoid accidentally using the 571 // page landed on instead of page 1. 572 if (typeof(viewData.page) === 'undefined') { 573 viewData.page = 0; 574 } 575 576 // Construct an object using the settings defaults and then overriding 577 // with data specific to the link. 578 $.extend( 579 viewData, 580 this.settings, 581 Drupal.Views.parseQueryString(href), 582 // Extract argument data from the URL. 583 Drupal.Views.parseViewArgs(href, this.settings.view_base_path) 584 ); 585 586 // For anchor tags, these will go to the target of the anchor rather 587 // than the usual location. 588 $.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path)); 589 590 // Construct an object using the element settings defaults, 591 // then overriding submit with viewData. 592 var pager_settings = $.extend({}, this.element_settings); 593 pager_settings.submit = viewData; 594 this.pagerAjax = new Drupal.ajax(false, $link, pager_settings); 595 this.links.push(this.pagerAjax); 596 }; 597 598 Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) { 599 // Scroll to the top of the view. This will allow users 600 // to browse newly loaded content after e.g. clicking a pager 601 // link. 602 var offset = $(response.selector).offset(); 603 // We can't guarantee that the scrollable object should be 604 // the body, as the view could be embedded in something 605 // more complex such as a modal popup. Recurse up the DOM 606 // and scroll the first element that has a non-zero top. 607 var scrollTarget = response.selector; 608 while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) { 609 scrollTarget = $(scrollTarget).parent(); 610 } 611 // Only scroll upward. 612 if (offset.top - 10 < $(scrollTarget).scrollTop()) { 613 $(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500); 614 } 615 }; 616 617})(jQuery); 618;
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.