1/** 2 * @file js/controllers/UrlInDivHandler.js 3 * 4 * Copyright (c) 2013-2015 Simon Fraser University Library 5 * Copyright (c) 2000-2015 John Willinsky 6 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. 7 * 8 * @class UrlInDivHandler 9 * @ingroup js_controllers 10 * 11 * @brief "URL in div" handler 12 */ 13(function($) { 14 15 16 /** 17 * @constructor 18 * 19 * @extends $.pkp.classes.Handler 20 * 21 * @param {jQueryObject} $divElement the wrapped div element. 22 * @param {Object} options options to be passed. 23 */ 24 $.pkp.controllers.UrlInDivHandler = function($divElement, options) { 25 this.parent($divElement, options); 26 27 // Store the URL (e.g. for reloads) 28 this.sourceUrl_ = options.sourceUrl; 29 30 // Load the contents. 31 this.reload(); 32 }; 33 $.pkp.classes.Helper.inherits( 34 $.pkp.controllers.UrlInDivHandler, $.pkp.classes.Handler); 35 36 37 // 38 // Private properties 39 // 40 /** 41 * The URL to be used for data loaded into this div 42 * @private 43 * @type {?string} 44 */ 45 $.pkp.controllers.UrlInDivHandler.sourceUrl_ = null; 46 47 48 // 49 // Public Methods 50 // 51 /** 52 * Reload the div contents. 53 */ 54 $.pkp.controllers.UrlInDivHandler.prototype.reload = function() { 55 $.get(this.sourceUrl_, 56 this.callbackWrapper(this.handleLoadedContent_), 'json'); 57 }; 58 59 60 // 61 // Private Methods 62 // 63 /** 64 * Handle a callback after a load operation returns. 65 * 66 * @param {Object} ajaxContext The AJAX request context. 67 * @param {Object} jsonData A parsed JSON response object. 68 * @return {boolean} Message handling result. 69 * @private 70 */ 71 /*jslint unparam: true*/ 72 $.pkp.controllers.UrlInDivHandler.prototype.handleLoadedContent_ = 73 function(ajaxContext, jsonData) { 74 75 var handledJsonData = this.handleJson(jsonData); 76 if (handledJsonData.status === true) { 77 this.getHtmlElement().hide().html(handledJsonData.content).fadeIn(400); 78 } else { 79 // Alert that loading failed. 80 alert(handledJsonData.content); 81 } 82 83 return false; 84 }; 85 /*jslint unparam: false*/ 86 87/** @param {jQuery} $ jQuery closure. */ 88}(jQuery));
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.