Add JS files

This commit is contained in:
2025-05-12 15:45:17 +00:00
parent 7ddd15c4fa
commit 967007b0c7
3239 changed files with 1157078 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
/*
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 3.0.0
build: 1549
*/
YUI.add("history",function(A){var C=A.config.win,U=A.config.doc,D=encodeURIComponent,O=decodeURIComponent,J,K,R="Missing or invalid argument",M=/([^=&]+)=([^&]*)/g,B=false,N,L="history:ready",Q="history:globalStateChange",F="history:moduleStateChange";if(!YUI.Env.history){YUI.Env.history=K={ready:false,_modules:[],_stateField:null,_historyIFrame:null};}if(A.UA.gecko){N=function(){var G=/#(.*)$/.exec(C.location.href);return G&&G[1]?G[1]:"";};}else{N=function(){return C.location.hash.substr(1);};}function S(){var H=[],G=[];A.Object.each(K._modules,function(V,W){H.push(W+"="+V.initialState);G.push(W+"="+V.currentState);});K._stateField.set("value",H.join("&")+"|"+G.join("&"));}function P(W){var G,V=[],H=false;if(W){M.lastIndex=0;while((G=M.exec(W))){V[G[1]]=G[2];}A.Object.each(K._modules,function(X,Z){var Y=V[Z];if(!Y||X.currentState!==Y){X.currentState=Y||X.initialState;X.fire(F,O(X.currentState));H=true;}});}else{A.Object.each(K._modules,function(X,Y){if(X.currentState!==X.initialState){X.currentState=X.initialState;X.fire(F,O(X.currentState));H=true;}});}if(H){J.fire(Q);}}function I(W){var G,V;G="<html><body>"+W+"</body></html>";try{V=K._historyIFrame.get("contentWindow.document");V.invoke("open");V.invoke("write",G,"","","","");V.invoke("close");return true;}catch(H){return false;}}function E(){var G,V,H;if(!K._historyIFrame.get("contentWindow.document")){setTimeout(E,10);return;}G=K._historyIFrame.get("contentWindow.document.body");V=G?G.get("innerText"):null;H=N();setInterval(function(){var Y,W,X;G=K._historyIFrame.get("contentWindow.document.body");Y=G?G.get("innerText"):null;X=N();if(Y!==V){V=Y;P(V);if(!V){W=[];A.Object.each(K._modules,function(Z,a){W.push(a+"="+Z.initialState);});X=W.join("&");}else{X=V;}C.location.hash=H=X;S();}else{if(X!==H){H=X;I(X);}}},50);K.ready=true;J.fire(L);}function T(){var H,Z,X,V,G,W,Y;Z=K._stateField.get("value").split("|");if(Z.length>1){M.lastIndex=0;while((H=M.exec(Z[0]))){X=H[1];G=H[2];V=K._modules[X];if(V){V.initialState=G;}}M.lastIndex=0;while((H=M.exec(Z[1]))){X=H[1];W=H[2];V=K._modules[X];if(V){V.currentState=W;}}}if(!A.Lang.isUndefined(C.onhashchange)&&(A.Lang.isUndefined(U.documentMode)||U.documentMode>7)){C.onhashchange=function(){var a=N();P(a);S();};K.ready=true;J.fire(L);}else{if(B){E();}else{Y=N();setInterval(function(){var a=N();if(a!==Y){Y=a;P(Y);S();}},50);K.ready=true;J.fire(L);}}}J={register:function(V,G){var H;if(!A.Lang.isString(V)||A.Lang.trim(V)===""||!A.Lang.isString(G)){throw new Error(R);}V=D(V);G=D(G);if(K._modules[V]){return;}if(K.ready){return null;}H=new J.Module(V,G);K._modules[V]=H;return H;},initialize:function(G,W){var H,V;if(K.ready){return true;}G=A.get(G);if(!G){throw new Error(R);}H=G.get("tagName").toUpperCase();V=G.get("type");if(H!=="TEXTAREA"&&(H!=="INPUT"||V!=="hidden"&&V!=="text")){throw new Error(R);}if(A.UA.ie&&(A.Lang.isUndefined(U.documentMode)||U.documentMode<8)){B=true;W=A.get(W);if(!W||W.get("tagName").toUpperCase()!=="IFRAME"){throw new Error(R);}}if(A.UA.opera&&!A.Lang.isUndefined(C.history.navigationMode)){C.history.navigationMode="compatible";}K._stateField=G;K._historyIFrame=W;A.on("domready",T);return true;},navigate:function(H,V){var G;if(!A.Lang.isString(H)||!A.Lang.isString(V)){throw new Error(R);}G={};G[H]=V;return J.multiNavigate(G);},multiNavigate:function(H){var V=[],W,G=false;if(!K.ready){return false;}A.Object.each(K._modules,function(Y,Z){var a,X=O(Z);if(!H.hasOwnProperty(X)){a=Y.currentState;}else{a=D(H[X]);if(a!==Y.upcomingState){Y.upcomingState=a;G=true;}}V.push(Z+"="+a);});if(!G){return false;}W=V.join("&");if(B){return I(W);}else{C.location.hash=W;return true;}},getCurrentState:function(H){var G;if(!A.Lang.isString(H)){throw new Error(R);}if(!K.ready){return null;}H=D(H);G=K._modules[H];if(!G){return null;}return O(G.currentState);},getBookmarkedState:function(W){var G,H,V;if(!A.Lang.isString(W)){throw new Error(R);}W=D(W);V=C.location.href;H=V.indexOf("#");if(H>=0){V=V.substr(H+1);M.lastIndex=0;while((G=M.exec(V))){if(G[1]===W){return O(G[2]);}}}return null;},getQueryStringParameter:function(X,H){var G,W,V;H=H||C.location.href;V=H.indexOf("?");W=V>=0?H.substr(V+1):H;V=W.lastIndexOf("#");W=V>=0?W.substr(0,V):W;M.lastIndex=0;while((G=M.exec(W))){if(G[1]===X){return O(G[2]);}}return null;}};A.mix(J,A.Event.Target.prototype);A.Event.Target.call(J);J.Module=function(H,G){A.Event.Target.call(this);this.id=H;this.initialState=G;this.currentState=G;this.upcomingState=G;};A.mix(J.Module,A.Event.Target,false,null,1);A.History=J;},"3.0.0",{skinnable:false,use:["event","node"]});

View File

@@ -0,0 +1,680 @@
/*
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 3.0.0
build: 1549
*/
YUI.add('history', function(Y) {
/*global YUI */
/**
* The Browser History Utility provides the ability to use the back/forward
* navigation buttons in a DHTML application. It also allows a DHTML
* application to be bookmarked in a specific state.
*
* This utility requires the following static markup:
*
* &lt;iframe id="yui-history-iframe" src="path-to-real-asset-in-same-domain"&gt;&lt;/iframe&gt;
* &lt;input id="yui-history-field" type="hidden"&gt;
*
* @module history
*/
/**
* This class represents an instance of the browser history utility.
* @class History
* @constructor
*/
// Shortcuts, etc.
var win = Y.config.win,
doc = Y.config.doc,
encode = encodeURIComponent,
decode = decodeURIComponent,
H, G,
// YUI Compressor helper...
E_MISSING_OR_INVALID_ARG = 'Missing or invalid argument',
// Regular expression used to parse query strings and such.
REGEXP = /([^=&]+)=([^&]*)/g,
// A few private variables...
_useIFrame = false,
_getHash,
/**
* @event history:ready
* @description Fires when the browser history utility is ready
* @type Event.Custom
*/
EV_HISTORY_READY = 'history:ready',
/**
* @event history:globalStateChange
* @description Fires when the global state of the page has changed (that is,
* when the state of at least one browser history module has changed)
* @type Event.Custom
*/
EV_HISTORY_GLOBAL_STATE_CHANGE = 'history:globalStateChange',
/**
* @event history:moduleStateChange
* @description Fires when the state of a history module object has changed
* @type Event.Custom
*/
EV_HISTORY_MODULE_STATE_CHANGE = 'history:moduleStateChange';
if (!YUI.Env.history) {
YUI.Env.history = G = {
// Flag used to tell whether the history utility is ready to be used.
ready: false,
// List of registered modules.
_modules: [],
// INPUT field (with type="hidden" or type="text") or TEXTAREA.
// This field keeps the value of the initial state, current state
// the list of all states across pages within a single browser session.
_stateField: null,
// Hidden IFrame used to store the browsing history on IE6/7.
_historyIFrame: null
};
}
/**
* Returns the portion of the hash after the '#' symbol.
* @method _getHash
* @return {string} The hash portion of the document's location
* @private
*/
if (Y.UA.gecko) {
// We branch at runtime for Gecko since window.location.hash in Gecko
// returns a decoded string, and we want all encoding untouched.
_getHash = function () {
var m = /#(.*)$/.exec(win.location.href);
return m && m[1] ? m[1] : '';
};
} else {
_getHash = function () {
return win.location.hash.substr(1);
};
}
/**
* Stores the initial state and current state for all registered modules
* in the (hidden) form field specified during initialization.
* @method _storeStates
* @private
*/
function _storeStates() {
var initialStates = [], currentStates = [];
Y.Object.each(G._modules, function (module, moduleId) {
initialStates.push(moduleId + '=' + module.initialState);
currentStates.push(moduleId + '=' + module.currentState);
});
G._stateField.set('value', initialStates.join('&') + '|' + currentStates.join('&'));
}
/**
* Sets the new currentState attribute of all modules depending on the new fully
* qualified state. Also notifies the modules which current state has changed.
* @method _handleFQStateChange
* @param {string} fqstate fully qualified state
* @private
*/
function _handleFQStateChange(fqstate) {
var m, states = [], globalStateChanged = false;
if (fqstate) {
REGEXP.lastIndex = 0;
while ((m = REGEXP.exec(fqstate))) {
states[m[1]] = m[2];
}
Y.Object.each(G._modules, function (module, moduleId) {
var currentState = states[moduleId];
if (!currentState || module.currentState !== currentState) {
module.currentState = currentState || module.initialState;
module.fire(EV_HISTORY_MODULE_STATE_CHANGE, decode(module.currentState));
globalStateChanged = true;
}
});
} else {
Y.Object.each(G._modules, function (module, moduleId) {
if (module.currentState !== module.initialState) {
module.currentState = module.initialState;
module.fire(EV_HISTORY_MODULE_STATE_CHANGE, decode(module.currentState));
globalStateChanged = true;
}
});
}
if (globalStateChanged) {
H.fire(EV_HISTORY_GLOBAL_STATE_CHANGE);
}
}
/**
* Update the IFrame with our new state.
* @method _updateIFrame
* @private
* @return {boolean} true if successful. false otherwise.
*/
function _updateIFrame(fqstate) {
var html, doc;
html = '<html><body>' + fqstate + '</body></html>';
try {
doc = G._historyIFrame.get('contentWindow.document');
// TODO: The Node API should expose these methods in the very near future...
doc.invoke('open');
doc.invoke('write', html, '', '', '', ''); // see bug #2447937
doc.invoke('close');
return true;
} catch (e) {
return false;
}
}
/**
* Periodically checks whether our internal IFrame is ready to be used
* @method _checkIframeLoaded
* @private
*/
function _checkIframeLoaded() {
var elem, fqstate, hash;
if (!G._historyIFrame.get('contentWindow.document')) {
// Check again in 10 msec...
setTimeout(_checkIframeLoaded, 10);
return;
}
// Periodically check whether a navigate operation has been
// requested on the main window. This will happen when
// History.navigate has been called or after the user
// has hit the back/forward button.
elem = G._historyIFrame.get('contentWindow.document.body');
// We must use innerText, and not innerHTML because our string contains
// the "&" character (which would end up being escaped as "&amp;") and
// the string comparison would fail...
fqstate = elem ? elem.get('innerText') : null;
hash = _getHash();
setInterval(function () {
var newfqstate, states, newHash;
elem = G._historyIFrame.get('contentWindow.document.body');
// See my comment above about using innerText instead of innerHTML...
newfqstate = elem ? elem.get('innerText') : null;
newHash = _getHash();
if (newfqstate !== fqstate) {
fqstate = newfqstate;
_handleFQStateChange(fqstate);
if (!fqstate) {
states = [];
Y.Object.each(G._modules, function (module, moduleId) {
states.push(moduleId + '=' + module.initialState);
});
newHash = states.join('&');
} else {
newHash = fqstate;
}
// Allow the state to be bookmarked by setting the top window's
// URL fragment identifier. Note that here, we are on IE < 8
// which does not touch the browser history when changing the
// hash (unlike all the other browsers).
win.location.hash = hash = newHash;
_storeStates();
} else if (newHash !== hash) {
// The hash has changed. The user might have clicked on a link,
// or modified the URL directly, or opened the same application
// bookmarked in a specific state using a bookmark. However, we
// know the hash change was not caused by a hit on the back or
// forward buttons, or by a call to navigate() (because it would
// have been handled above) We must handle these cases, which is
// why we also need to keep track of hash changes on IE!
// Note that IE6 has some major issues with this kind of user
// interaction (the history stack gets completely messed up)
// but it seems to work fine on IE7.
hash = newHash;
// Now, store a new history entry. The following will cause the
// code above to execute, doing all the dirty work for us...
_updateIFrame(newHash);
}
}, 50);
G.ready = true;
H.fire(EV_HISTORY_READY);
}
/**
* Finish up the initialization of the browser utility library.
* @method _initialize
* @private
*/
function _initialize() {
var m, parts, moduleId, module, initialState, currentState, hash;
// Decode the content of our storage field...
parts = G._stateField.get('value').split('|');
if (parts.length > 1) {
REGEXP.lastIndex = 0;
while ((m = REGEXP.exec(parts[0]))) {
moduleId = m[1];
initialState = m[2];
module = G._modules[moduleId];
if (module) {
module.initialState = initialState;
}
}
REGEXP.lastIndex = 0;
while ((m = REGEXP.exec(parts[1]))) {
moduleId = m[1];
currentState = m[2];
module = G._modules[moduleId];
if (module) {
module.currentState = currentState;
}
}
}
// IE8 in IE7 mode defines window.onhashchange, but never fires it...
if (!Y.Lang.isUndefined(win.onhashchange) &&
(Y.Lang.isUndefined(doc.documentMode) || doc.documentMode > 7)) {
// The HTML5 way of handling DHTML history...
win.onhashchange = function () {
var hash = _getHash();
_handleFQStateChange(hash);
_storeStates();
};
G.ready = true;
H.fire(EV_HISTORY_READY);
} else if (_useIFrame) {
// IE < 8 or IE8 in quirks mode or IE7 standards mode
_checkIframeLoaded();
} else {
// Periodically check whether a navigate operation has been
// requested on the main window. This will happen when
// History.navigate has been called, or after the user
// has hit the back/forward button.
// On Gecko and Opera, we just need to watch the hash...
hash = _getHash();
setInterval(function () {
var newHash = _getHash();
if (newHash !== hash) {
hash = newHash;
_handleFQStateChange(hash);
_storeStates();
}
}, 50);
G.ready = true;
H.fire(EV_HISTORY_READY);
}
}
H = {
/**
* Registers a new module.
* @method register
* @param {string} moduleId Non-empty string uniquely identifying the
* module you wish to register.
* @param {string} initialState The initial state of the specified
* module corresponding to its earliest history entry.
* @return {History.Module} The newly registered module
*/
register: function (moduleId, initialState) {
var module;
if (!Y.Lang.isString(moduleId) || Y.Lang.trim(moduleId) === '' || !Y.Lang.isString(initialState)) {
throw new Error(E_MISSING_OR_INVALID_ARG);
}
moduleId = encode(moduleId);
initialState = encode(initialState);
if (G._modules[moduleId]) {
// The module seems to have already been registered.
return;
}
// Note: A module CANNOT be registered once the browser history
// utility has been initialized. This is related to reading and
// writing state values from/to the input field. Relaxing this
// rule would potentially create situations rather complicated
// to deal with.
if (G.ready) {
return null;
}
module = new H.Module(moduleId, initialState);
G._modules[moduleId] = module;
return module;
},
/**
* Initializes the Browser History Manager. Call this method
* from a script block located right after the opening body tag.
* @method initialize
* @param {string|HTML Element} stateField <input type="hidden"> used
* to store application states. Must be in the static markup.
* @param {string|HTML Element} historyIFrame IFrame used to store
* the history (only required for IE6/7)
* @public
*/
initialize: function (stateField, historyIFrame) {
var tagName, type;
if (G.ready) {
// The browser history utility has already been initialized.
return true;
}
stateField = Y.get(stateField);
if (!stateField) {
throw new Error(E_MISSING_OR_INVALID_ARG);
}
tagName = stateField.get('tagName').toUpperCase();
type = stateField.get('type');
if (tagName !== 'TEXTAREA' && (tagName !== 'INPUT' || type !== 'hidden' && type !== 'text')) {
throw new Error(E_MISSING_OR_INVALID_ARG);
}
// IE < 8 or IE8 in quirks mode or IE7 standards mode
if (Y.UA.ie && (Y.Lang.isUndefined(doc.documentMode) || doc.documentMode < 8)) {
_useIFrame = true;
historyIFrame = Y.get(historyIFrame);
if (!historyIFrame || historyIFrame.get('tagName').toUpperCase() !== 'IFRAME') {
throw new Error(E_MISSING_OR_INVALID_ARG);
}
}
if (Y.UA.opera && !Y.Lang.isUndefined(win.history.navigationMode)) {
// Disable Opera's fast back/forward navigation mode and put
// it in compatible mode. This makes anchor-based history
// navigation work after the page has been navigated away
// from and re-activated, at the cost of slowing down
// back/forward navigation to and from that page.
win.history.navigationMode = 'compatible';
}
G._stateField = stateField;
G._historyIFrame = historyIFrame;
Y.on('domready', _initialize);
return true;
},
/**
* Stores a new entry in the browser history by changing the state of a registered module.
* @method navigate
* @param {string} module Non-empty string representing your module.
* @param {string} state String representing the new state of the specified module.
* @return {boolean} Indicates whether the new state was successfully added to the history.
* @public
*/
navigate: function (moduleId, state) {
var states;
if (!Y.Lang.isString(moduleId) || !Y.Lang.isString(state)) {
throw new Error(E_MISSING_OR_INVALID_ARG);
}
// The ncoding of module id and state takes place in mutiNavigate.
states = {};
states[moduleId] = state;
return H.multiNavigate(states);
},
/**
* Stores a new entry in the browser history by changing the state
* of several registered modules in one atomic operation.
* @method multiNavigate
* @param {object} states Associative array of module-state pairs to set simultaneously.
* @return {boolean} Indicates whether the new state was successfully added to the history.
* @public
*/
multiNavigate: function (states) {
var newStates = [], fqstate, globalStateChanged = false;
if (!G.ready) {
return false;
}
Y.Object.each(G._modules, function (module, moduleId) {
var state, decodedModuleId = decode(moduleId);
if (!states.hasOwnProperty(decodedModuleId)) {
// The caller did not wish to modify the state of this
// module. We must however include it in fqstate!
state = module.currentState;
} else {
state = encode(states[decodedModuleId]);
if (state !== module.upcomingState) {
module.upcomingState = state;
globalStateChanged = true;
}
}
newStates.push(moduleId + '=' + state);
});
if (!globalStateChanged) {
// Nothing changed, so don't do anything.
return false;
}
fqstate = newStates.join('&');
if (_useIFrame) {
return _updateIFrame(fqstate);
} else {
win.location.hash = fqstate;
return true;
}
},
/**
* Returns the current state of the specified module.
* @method getCurrentState
* @param {string} moduleId Non-empty string representing your module.
* @return {string} The current state of the specified module.
* @public
*/
getCurrentState: function (moduleId) {
var module;
if (!Y.Lang.isString(moduleId)) {
throw new Error(E_MISSING_OR_INVALID_ARG);
}
if (!G.ready) {
return null;
}
moduleId = encode(moduleId);
module = G._modules[moduleId];
if (!module) {
return null;
}
return decode(module.currentState);
},
/**
* Returns the state of a module according to the URL fragment
* identifier. This method is useful to initialize your modules
* if your application was bookmarked from a particular state.
* @method getBookmarkedState
* @param {string} moduleId Non-empty string representing your module.
* @return {string} The bookmarked state of the specified module.
* @public
*/
getBookmarkedState: function (moduleId) {
var m, i, h;
if (!Y.Lang.isString(moduleId)) {
throw new Error(E_MISSING_OR_INVALID_ARG);
}
moduleId = encode(moduleId);
// Use location.href instead of location.hash which is already
// URL-decoded, which creates problems if the state value
// contained special characters...
h = win.location.href;
i = h.indexOf('#');
if (i >= 0) {
h = h.substr(i + 1);
REGEXP.lastIndex = 0;
while ((m = REGEXP.exec(h))) {
if (m[1] === moduleId) {
return decode(m[2]);
}
}
}
return null;
},
/**
* Returns the value of the specified query string parameter.
* This method is not used internally by the Browser History Manager.
* However, it is provided here as a helper since many applications
* using the Browser History Manager will want to read the value of
* url parameters to initialize themselves.
* @method getQueryStringParameter
* @param {string} paramName Name of the parameter we want to look up.
* @param {string} queryString Optional URL to look at. If not specified,
* this method uses the URL in the address bar.
* @return {string} The value of the specified parameter, or null.
* @public
*/
getQueryStringParameter: function (paramName, url) {
var m, q, i;
url = url || win.location.href;
i = url.indexOf('?');
q = i >= 0 ? url.substr(i + 1) : url;
// Remove the hash if any
i = q.lastIndexOf('#');
q = i >= 0 ? q.substr(0, i) : q;
REGEXP.lastIndex = 0;
while ((m = REGEXP.exec(q))) {
if (m[1] === paramName) {
return decode(m[2]);
}
}
return null;
}
};
// Make Y.History an event target
Y.mix(H, Y.Event.Target.prototype);
Y.Event.Target.call(H);
/**
* This class represents a browser history module.
* @class History.Module
* @constructor
* @param id {String} the module identifier
* @param initialState {String} the module's initial state
*/
H.Module = function (id, initialState) {
Y.Event.Target.call(this);
/**
* The module identifier
* @type String
* @final
*/
this.id = id;
/**
* The module's initial state
* @type String
* @final
*/
this.initialState = initialState;
/**
* The module's current state
* @type String
* @final
*/
this.currentState = initialState;
/**
* The module's upcoming state. There can be a slight delay between the
* time a state is changed, and the time a state change is detected.
* This property allows us to not fire the module state changed event
* multiple times, making client code simpler.
* @type String
* @private
* @final
*/
this.upcomingState = initialState;
};
Y.mix(H.Module, Y.Event.Target, false, null, 1);
Y.History = H;
}, '3.0.0' ,{skinnable:false, use:['event', 'node']});