1/* 2 * /js/cosme.js 3 * /js/dojo/dojo.js ˶ 4 */ 5 6(function () { 7 if (typeof cosmes == 'undefined') { 8 this.cosmes = { 9 '_scopeName' : 'cosmes' 10 }; 11 } 12 13 if (typeof cosme == 'undefined') { 14 this.cosme = { 15 'autoload' : [], 16 'onload' : [], 17 'preload' : [], 18 'global' : this, 19 'parameters' : {}, 20 '_scopeName' : 'cosme', 21 '_loaded' : {}, 22 '_parameters' : {}, 23 '_services' : this.cosmes 24 }; 25 } 26})(); 27 28/* 29 * ú»Æjü 30 */ 31 32cosme.initialize = function () { 33 if (dojo.isMozilla) { 34 window.addEventListener('load', function (e) { window.event = e; }, true); 35 window.addEventListener('click', function (e) { window.event = e; }, true); 36 window.addEventListener('submit', function (e) { window.event = e; }, true); 37 window.addEventListener('mouseup', function (e) { window.event = e; }, true); 38 window.addEventListener('mousedown', function (e) { window.event = e; }, true); 39 window.addEventListener('mousemove', function (e) { window.event = e; }, true); 40 window.addEventListener('mouseover', function (e) { window.event = e; }, true); 41 window.addEventListener('mouseout', function (e) { window.event = e; }, true); 42 window.addEventListener('scroll', function (e) { window.event = e; }, true); 43 window.addEventListener('keyup', function (e) { window.event = e; }, true); 44 window.addEventListener('keydown', function (e) { window.event = e; }, true); 45 window.addEventListener('keypress', function (e) { window.event = e; }, true); 46 } 47 try { cosme._autoloader(); } catch (e) { } 48 //try { cosme._onloader(); } catch (e) { } 49 cosme._onloader(); 50}; 51cosme.destructor = function () { 52}; 53 54/* 55 * î² 56 */ 57 58cosme.addOnLoad = function (methodName) { 59 return dojo.addOnLoad(methodName); 60}; 61cosme.addOnUnload = function (methodName) { 62 return dojo.addOnUnload(methodName); 63}; 64cosme.provide = function (moduleName) { 65 return dojo.provide(moduleName); 66}; 67cosme.require = function (moduleName) { 68 return dojo.require(moduleName); 69}; 70cosme.request = function (url, options) { 71 options = options || { 72 // form : tH[vf(DOM) 73 // handle : nhH 74 // handleAs : nhGCAXH 75 // method : NGXg\bh, 76 // parameters : p[^, 77 // postBody : NGXg{fB, 78 // requestHeaders : NGXgwb_, 79 // asynchronous : ñ¯úÊMtO, 80 // preventCache : LbV tO, 81 // contentType : Reg^Cvi¢Àj, 82 // onCreate : IuWFNgì¬Ìi¢Àj, 83 // onLoading : ÇÝÝJnÌi¢Àj, 84 // onLoaded : ÇÝÝI¹Ìi¢Àj, 85 // onSuccess : ÇÝݬ÷Ìi¢Àj, 86 // onFailure : ÊM¸sÌ, 87 // onComplete : ÊM®¹Ì, 88 // onCallback : ®¹ãÌ 89 // onException : áOi¢Àj, 90 }; 91 92 if (typeof url === 'undefined') 93 throw new Error('urlªÝè³êĢܹñB'); 94 95 if (typeof options.onComplete !== 'function') 96 throw new Error('onComleteªfunctionÅÍ èܹñB'); 97 98 // postBody 99 if (options.postBody) { 100 options.method = 'post'; 101 options.parameters += (options.parameters ? '&' : '') + options.postBody 102 } else { 103 options.method = options.method || 'get'; 104 } 105 106 // requestHeaders 107 options.requestHeaders = options.requestHeaders || {}; 108 109 // requestHeaders.X-Cosme-Content-Type 110 options.requestHeaders['X-Cosme-Content-Type'] = 111 options.requestHeaders['X-Cosme-Content-Type'] || ''; 112 113 // requestHeaders.X-Cosme-Charset 114 options.requestHeaders['X-Cosme-Charset'] = 115 options.requestHeaders['X-Cosme-Charset'] || 'Shift_JIS'; 116 117 var deferred = dojo.xhr( 118 options.method, { 119 content : options.parameters, 120 error : options.onFailure, 121 form : options.form, 122 handle : options.handle, 123 handleAs : options.handleAs, 124 headers : options.requestHeaders, 125 load : options.onComplete, 126 preventCache : options.preventCache, 127 sync : (options.asynchronous == null) ? false : !options.asynchronous, 128 timeout : null, 129 url : url 130 }, 131 (options.method.toLowerCase() === 'post') ? true : false); 132 133 deferred.addCallback(options.onCallback); 134 deferred.addErrback(options.onException); 135 136 return deferred; 137}; 138cosme.fromJson = function (string) { 139 return dojo.fromJson(string); 140}; 141cosme.setConfig = function (key, config) { 142 this[key] = config; 143}; 144cosme.coords = function (elem) { 145 var coords = dojo.coords(elem); 146 147 if (dojo.isIE <= 7 && elem.offsetParent) { 148 coords.t += dojo.style(elem.offsetParent, 'marginTop'); 149 coords.l += dojo.style(elem.offsetParent, 'marginLeft'); 150 } 151 152 return coords; 153}; 154 155/* 156 * updaten 157 */ 158 159cosme.update = function (node, options) { 160 this.event.stop(); 161 162 node = (node && node.tagName) ? node : this.getNode(node); 163 options = options || { /* cosme.request() QÆ */ }; 164 165 if (typeof node === 'undefined') 166 throw new Error('nodeªwè³êĢܹñB'); 167 168 var url = options.url 169 || this.event.target().getAttribute('url', 2) 170 || this.event.target().getAttribute('href', 2); 171 172 if (typeof url === 'undefined') 173 throw new Error('urlªÝè³êĢܹñB'); 174 175 if (!options.parameters) { 176 var _params = this.event.target().getAttribute('parameters'); 177 options.parameters = (!!_params) ? this.fromJson('{' + _params + '}') : null; 178 } 179 180 if (!options.onComplete) { 181 options.onComplete = function (data, xhr) { node.innerHTML = data; }; } 182 183 options.preventCache = (options.preventCache == null) ? true : options.preventCache; 184 185 var deferred = this.request(url, options); 186}; 187cosme.updateId = function (id, options) { 188 this.update(this.getNodeById(id), options) 189}; 190cosme.updateSelector = function (selector, options) { 191 this.update(this.getNodesBySelector(selector)[0], options); 192}; 193 194/* 195 * DOMn 196 */ 197 198cosme.node = function (node) { 199 if (this._loaded['node'] == null) { 200 this.require('cosme.Node'); 201 this._loaded['node'] = new cosme.Node({ node : node }); 202 } 203 204 if (node) 205 this._loaded['node'].setNode(node); 206 207 return this._loaded['node']; 208}; 209cosme.getNode = function (_node, parent) {
210 var node = this.getNodeById(_node, parent); 211 return (!!node) ? node : this.getNodesBySelector(_node)[0]; 212}; 213cosme.getNodeById = function (id, parent) { 214 return dojo.byId(id, parent); 215}; 216cosme.getElementById = function (id, parent) { 217 return this.getNodeById(id, parent); 218}; 219cosme.getNodes = function (selector, parent) { 220 return this.getNodesBySelector(selector, parent); 221}; 222cosme.getNodesBySelector = function (selector, parent) { 223 return dojo.query(selector, parent) 224}; 225cosme.getElementsBySelector = function (selector, parent) { 226 return this.getNodesBySelector(selector, parent) 227}; 228 229/* 230 * ecl 231 */ 232 233cosme.ecl = function () { 234 cosme.require('cosme._ecl'); 235 return this._ecl; 236}; 237 238/* 239 * locationn 240 * gíÈ»¤¾È[Æv¢Â 241 */ 242 243cosme.location = { 244 href : function (href) { 245 location.href = href; 246 } 247}; 248 249/* 250 * eventn 251 */ 252 253cosme.event = { 254 get : function (key) { 255 return (key) ? dojo.fixEvent(window.event)[key] : dojo.fixEvent(window.event); 256 }, 257 target : function () { 258 return this.get().target; 259 }, 260 stop : function () { 261 dojo.stopEvent(this.get()); 262 } 263}; 264 265/* 266 * windown 267 */ 268 269cosme.window = { 270 'innerWidth' : function () { 271 return document.body.clientWidth 272 || document.documentElement.clientWidth 273 || window.innerWidth 274 || 0; 275 }, 276 'innerHeight' : function () { 277 return document.body.clientHeight 278 || document.documentElement.clientHeight 279 || window.innerHeight 280 || 0; 281 }, 282 'scrollTop' : function () { 283 return document.body.scrollTop 284 || document.documentElement.scrollTop 285 || window.pageYOffset 286 || 0; 287 }, 288 'scrollLeft' : function () { 289 return document.body.scrollLeft 290 || document.documentElement.scrollLeft 291 || window.pageXOffset 292 || 0; 293 } 294}; 295 296/* 297 * private 298 */ 299 300cosme._autoloader = function () { 301 for (var i = 0; i < arguments.length; ++i) { 302 if (arguments[i]) 303 this.require(arguments[i]); 304 } 305 306 if (!this.autoload) 307 return; 308 309 if (typeof this.autoload === 'string') 310 this.autoload = [this.autoload]; 311 312 for (var i = 0; i < this.autoload.length; ++i) { 313 if (this.autoload[i]) 314 this.require(this._services._scopeName + '.' + this.autoload[i]); 315 } 316}; 317cosme._onloader = function () { 318 if (!this.onload) 319 return; 320 321 if (typeof this.onload === 'string') 322 this.onload = [this.onload]; 323 324 ONLOADER: for (var j = 0; j < this.onload.length; ++j) { 325 var obj = this.global[this._services._scopeName]; 326 var scopes = this.onload[j].split('.'); 327 for (var i = 0; i < scopes.length; ++i) { 328 if (obj[scopes[i]]) 329 obj = obj[scopes[i]]; 330 else 331 continue ONLOADER; 332 } 333 try { 334 obj(cosme.parameters); 335 } 336 catch (e) { 337 console.log('error'); 338 console.log(e); 339 } 340 } 341}; 342 343cosme._preloader = function () { 344 if (!this.preload) 345 return; 346 347 if (typeof this.preload === 'string') 348 this.preload = [this.preload]; 349 350 for (var i = 0; i < this.preload.length; i++) { 351 this.require(this._services._scopeName + '.' + this.preload[i]); 352 } 353}; 354 355(function () { 356 var cosmeScript = cosme.getNode('script[cosmeConfig]'); 357 var configString = cosmeScript.getAttribute('cosmeConfig'); 358 var paramsString = cosmeScript.getAttribute('cosmeParameter'); 359 360 var cosmeConfig = cosme.fromJson('{' + configString + '}'); 361 cosme.parameters = cosme.fromJson(paramsString || '{}'); 362 363 for (key in cosmeConfig) 364 cosme.setConfig(key, cosmeConfig[key]); 365 366 // w誳¢êÍ^CX^vðg¤ 367 if (cosmeConfig['cacheBust'] == null) { 368 dojo.config.cacheBust = (new Date()).getTime(); 369 } else { 370 dojo.config.cacheBust = cosmeConfig['cacheBust']; 371 } 372 373 cosme._preloader(); 374 375 cosme.addOnLoad(cosme.initialize); 376 cosme.addOnUnload(cosme.destructor); 377})();
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.