• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account Log out
  • Favorite
  • Project
  • Recent History
Loading...
  • Log in
  • Sign up
kadrians / Testing_for_YONA star
  • Project homeH
  • CodeC
  • IssueI 1
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB 2
  • Files
  • Commit
  • Branches
Testing_for_YONAsourcepublicjavascriptslibjqueryjquery.requestAs.js
Download as .zip file
File name
Commit message
Commit date
bin
Yona 1.16.0 Upload
02-04
lib
Yona 1.16.0 Upload
02-04
share/doc/api
Yona 1.16.0 Upload
02-04
source
Source Code Upload
02-04
README.md
Yona 1.16.0 Upload
02-04
File name
Commit message
Commit date
app
Source Code Upload
02-04
conf
Source Code Upload
02-04
docs
Source Code Upload
02-04
lib
Source Code Upload
02-04
project
Source Code Upload
02-04
public
Source Code Upload
02-04
support-script
Source Code Upload
02-04
test
Source Code Upload
02-04
.gitignore
Source Code Upload
02-04
.mailmap
Source Code Upload
02-04
.travis.yml
Source Code Upload
02-04
AUTHORS
Source Code Upload
02-04
LICENSE
Source Code Upload
02-04
NOTICE
Source Code Upload
02-04
README.md
Source Code Upload
02-04
build.sbt
Source Code Upload
02-04
dev.sh
Source Code Upload
02-04
dist.sh
Source Code Upload
02-04
is-alive-bot.sh
Source Code Upload
02-04
minify-js.sh
Source Code Upload
02-04
restart.sh
Source Code Upload
02-04
File name
Commit message
Commit date
bootstrap
Source Code Upload
02-04
help
Source Code Upload
02-04
images
Source Code Upload
02-04
javascripts
Source Code Upload
02-04
stylesheets
Source Code Upload
02-04
compiler.jar
Source Code Upload
02-04
File name
Commit message
Commit date
common
Source Code Upload
02-04
lib
Source Code Upload
02-04
service
Source Code Upload
02-04
template
Source Code Upload
02-04
yona-common.js
Source Code Upload
02-04
yona-layout.js
Source Code Upload
02-04
yona-lib.js
Source Code Upload
02-04
File name
Commit message
Commit date
ace
Source Code Upload
02-04
atjs
Source Code Upload
02-04
autosize
Source Code Upload
02-04
elevator
Source Code Upload
02-04
favico
Source Code Upload
02-04
highlight
Source Code Upload
02-04
jquery
Source Code Upload
02-04
magnific-popup
Source Code Upload
02-04
mentionjs
Source Code Upload
02-04
nprogress
Source Code Upload
02-04
pikaday
Source Code Upload
02-04
select2
Source Code Upload
02-04
tasklist
Source Code Upload
02-04
tippy
Source Code Upload
02-04
videojs
Source Code Upload
02-04
viewerjs
Source Code Upload
02-04
canvas-to-blob.js
Source Code Upload
02-04
clipboard.js
Source Code Upload
02-04
diff.js
Source Code Upload
02-04
filetype.js
Source Code Upload
02-04
humanize.js
Source Code Upload
02-04
jquery.pageslide.js
Source Code Upload
02-04
less-1.3.0.min.js
Source Code Upload
02-04
marked.js
Source Code Upload
02-04
moment-with-langs.min.js
Source Code Upload
02-04
parseuri.js
Source Code Upload
02-04
rgbcolor.js
Source Code Upload
02-04
underscore.js
Source Code Upload
02-04
validate.js
Source Code Upload
02-04
vendor.js
Source Code Upload
02-04
xss.js
Source Code Upload
02-04
File name
Commit message
Commit date
ZeroClipboard.swf
Source Code Upload
02-04
jquery-1.7.2.js
Source Code Upload
02-04
jquery-1.7.2.min.js
Source Code Upload
02-04
jquery-1.9.0.js
Source Code Upload
02-04
jquery-3.3.1.js
Source Code Upload
02-04
jquery-ui-1.10.4.custom.min.js
Source Code Upload
02-04
jquery-ui.custom.js
Source Code Upload
02-04
jquery.Jcrop.min.js
Source Code Upload
02-04
jquery.browser.js
Source Code Upload
02-04
jquery.cookie.js
Source Code Upload
02-04
jquery.dynatree.js
Source Code Upload
02-04
jquery.event.drag-2.2.js
Source Code Upload
02-04
jquery.form.js
Source Code Upload
02-04
jquery.pjax.js
Source Code Upload
02-04
jquery.placeholder.min.js
Source Code Upload
02-04
jquery.requestAs.js
Source Code Upload
02-04
jquery.scrollTo.js
Source Code Upload
02-04
jquery.search.js
Source Code Upload
02-04
jquery.tmpl.js
Source Code Upload
02-04
jquery.validate.js
Source Code Upload
02-04
jquery.validate.min.js
Source Code Upload
02-04
jquery.zclip.min.js
Source Code Upload
02-04
Nell 02-04 2600fe6 Source Code Upload UNIX
Raw Open in browser Change history
/** * jQuery.requestAs * https://github.com/nforge/jquery-plugin-requestAs * * Copyright (c) 2013 JiHan Kim * Date: 2013/08/30 * * @author JiHan Kim <laziel@naver.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ !function($){ "use strict"; var RequestAs = function(elContainer, htOptions){ this.init(elContainer, htOptions); // jQuery style interfaces this.options = this._htData; this.on = this._attachCustomEvent; this.off = this._detachCustomEvent; }; RequestAs.prototype = { "constructor": RequestAs, /** * Attach event handler on available target elements */ "init": function(elContainer, htOptions){ var welTarget = $(elContainer); this._htData = this._getRequestOptions(welTarget, htOptions || {}); this._htHandlers = {}; // if target element is anchor and request method is GET // plain HTML will works enough. if(this._htData.sMethod === "get" && el.tagName.toLowerCase() === "a"){ return; } // legacy compatibility if(typeof this._htData.fOnLoad === "function"){ this._attachCustomEvent("load", htOptions.fOnLoad); } if(typeof this._htData.fOnError === "function"){ this._attachCustomEvent("error", htOptions.fOnError); } // Set cursor style on target welTarget.css("cursor", "pointer"); // Send request on click or keydown enterkey welTarget.on("click keydown", $.proxy(this._onClickTarget, this)); // public interfaces return { "options": this._htData, "on" : this._attachCustomEvent, "off" : this._detachCustomEvent }; }, /** * Event Handler on target element * * @param {Wrapped Event} weEvt */ "_onClickTarget": function(weEvt){ if((weEvt.type === "keydown" && weEvt.keyCode !== 13) || !this._htData){ return; } this._sendRequest(this._htData); weEvt.preventDefault(); weEvt.stopPropagation(); return false; }, /** * Send request * * @param {Hash Table} htData */ "_sendRequest": function(htData){ var htReqOpt = { "method" : htData.sMethod, "success" : $.proxy(this._onSuccessRequest, this), "error" : $.proxy(this._onErrorRequest, this), "cache" : false, "dataType": "text" }; // if htAjaxOpt exists, it overrides current Ajax Options // $.ajax "data" option could be used with this if(htData.htAjaxOpt instanceof Object){ htReqOpt = $.extend(htReqOpt, htData.htAjaxOpt); } // fire custom event "beforeRequest" // if any event handler returns explicitly false(Boolean), // no request will be sent. var bCustomEventResult = this._fireEvent("beforeRequest", htReqOpt); if(bCustomEventResult === false){ return false; } $.ajax(htData.sHref, htReqOpt); }, /** * Get request options from target element * * @param {HTMLElement} elTarget * @param {Hash Table} htOptions */ "_getRequestOptions": function(elTarget, htOptions){ var welTarget = $(elTarget); return { "sMethod" : htOptions.sMethod || welTarget.data("request-method") || "get", "sHref" : htOptions.sHref || welTarget.data("request-uri") || welTarget.attr("href"), "fOnLoad" : htOptions.fOnLoad || undefined, "fOnError": htOptions.fOnError || undefined }; }, /** * Default callback for handle request success event * redirects to URL if server responses JSON data * (e.g. {"url":"http://www.foobar.com/"}) * or just reload current page * * @param {Object} oRes * @param {String} sStatus * @param {Object} oXHR */ "_onSuccessRequest": function(oRes, sStatus, oXHR){ // fire custom event "load" // if any event handler returns explicitly false(Boolean), // default action will be prevented. var bCustomEventResult = this._fireEvent("load", { "oRes" : oRes, "oXHR" : oXHR, "sStatus": sStatus }); if(bCustomEventResult === false){ return; } // default action below: var sLocation = oXHR.getResponseHeader("Location"); if(oXHR.status === 204 && sLocation){ document.location.href = sLocation; } else { document.location.reload(); } }, /** * Default callback for handle request error event * * @param {Object} oXHR */ "_onErrorRequest": function(oXHR){ // fire custom event "load" // if any event handler returns explicitly false(Boolean), // default action will be prevented. this._fireEvent("error", { "oXHR": oXHR }); // default action below: switch(oXHR.status){ case 200: // if server responses ok(200) but cannot determine redirect URL, // reload current page. document.location.reload(); break; case 204: // if server responses 204, it is client error. // in this case, check AJAX dataType option on _sendRequest document.location.href = oXHR.getResponseHeader("Location"); break; } // need to do something else? }, /** * Attach custom event handler * * @param {String} sEventName * @param {Function} fHandler * @param {String} sNamespace * @example * $("#button").data("requestAs").on("eventName", function(){}); * // or * $("#button").data("requestAs").on({ * "event1st": function(){}, * "event2nd": function(){} * }); */ "_attachCustomEvent": function(sEventName, fHandler){ if(typeof sEventName === "object"){ for(var sKey in sEventName){ this._htHandlers[sKey] = this._htHandlers[sKey] || []; this._htHandlers[sKey].push(sEventName[sKey]); } } else { this._htHandlers[sEventName] = this._htHandlers[sEventName] || []; this._htHandlers[sEventName].push(fHandler); } }, /** * Detach custom event handler * clears all handler of sEventName when fHandler is empty * * @param {String} sEventName * @param {Function} fHandler */ "_detachCustomEvent": function(sEventName, fHandler){ if(!fHandler){ this._htHandlers[sEventName] = []; return; } var aHandlers = this._htHandlers[sEventName]; var nIndex = aHandlers ? aHandlers.indexOf(fHandler) : -1; if(nIndex > -1){ this._htHandlers[sEventName].splice(nIndex, 1); } }, /** * Run specified custom event handlers * * @param {String} sEventName * @param {Object} oData */ "_fireEvent": function(sEventName, oData){ var aHandlers = this._htHandlers[sEventName]; if ((aHandlers instanceof Array) === false) { return; } var bResult = undefined; aHandlers.forEach(function(fHandler){ bResult = bResult || fHandler(oData); }); return bResult; } }; // RequestAs Plugin Definition var old = $.fn.requestAs; $.fn.requestAs = function(htOptions){ return this.each(function(){ var $this = $(this); var data = $this.data("requestAs"); if(!data){ $this.data("requestAs", data = new RequestAs(this, htOptions)); } if(typeof htOptions == "string") { data[htOptions](); } }); }; // RequestAs No Conflict $.fn.requestAs.noConflict = function(){ $.fn.requestAs = old; return this; }; // RequestAs DATA-API $(document).ready(function(){ $("[data-request-method]").requestAs(); }); }(window.jQuery);

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
login with Google Sign in with Google
Reset password | Sign up