Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

index.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. import _extends from 'babel-runtime/helpers/extends';
  2. import _typeof from 'babel-runtime/helpers/typeof';
  3. import _Promise from 'babel-runtime/core-js/promise';
  4. /*
  5. Copyright 2013-2015 ASIAL CORPORATION
  6. Licensed under the Apache License, Version 2.0 (the "License");
  7. you may not use this file except in compliance with the License.
  8. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. */
  16. import util from './util';
  17. import elements from './elements';
  18. import animit from './animit';
  19. import GestureDetector from './gesture-detector';
  20. import platform from './platform';
  21. import notification from './notification';
  22. import actionSheet from './action-sheet';
  23. import internal from './internal';
  24. import orientation from './orientation';
  25. import modifier from './modifier';
  26. import softwareKeyboard from './software-keyboard';
  27. import pageAttributeExpression from './page-attribute-expression';
  28. import autoStyle from './autostyle';
  29. import DoorLock from './doorlock';
  30. import { defaultPageLoader, PageLoader } from './page-loader';
  31. /**
  32. * @object ons
  33. * @category util
  34. * @description
  35. * [ja]Onsen UIで利用できるグローバルなオブジェクトです。[/ja]
  36. * [en]A global object that's used in Onsen UI. [/en]
  37. */
  38. var ons = {
  39. animit: animit,
  40. defaultPageLoader: defaultPageLoader,
  41. elements: elements,
  42. GestureDetector: GestureDetector,
  43. modifier: modifier,
  44. notification: notification,
  45. orientation: orientation,
  46. pageAttributeExpression: pageAttributeExpression,
  47. PageLoader: PageLoader,
  48. platform: platform,
  49. softwareKeyboard: softwareKeyboard,
  50. _autoStyle: autoStyle,
  51. _internal: internal,
  52. _readyLock: new DoorLock(),
  53. _util: util
  54. };
  55. ons.platform.select((window.location.search.match(/platform=([\w-]+)/) || [])[1]);
  56. waitDeviceReady();
  57. var readyError = function readyError(after) {
  58. return util.throw('This method must be called ' + (after ? 'after' : 'before') + ' ons.isReady() is true');
  59. };
  60. /**
  61. * @method isReady
  62. * @signature isReady()
  63. * @return {Boolean}
  64. * [en]Will be true if Onsen UI is initialized.[/en]
  65. * [ja]初期化されているかどうかを返します。[/ja]
  66. * @description
  67. * [en]Returns true if Onsen UI is initialized.[/en]
  68. * [ja]Onsen UIがすでに初期化されているかどうかを返すメソッドです。[/ja]
  69. */
  70. ons.isReady = function () {
  71. return !ons._readyLock.isLocked();
  72. };
  73. /**
  74. * @method isWebView
  75. * @signature isWebView()
  76. * @return {Boolean}
  77. * [en]Will be true if the app is running in Cordova.[/en]
  78. * [ja]Cordovaで実行されている場合にtrueになります。[/ja]
  79. * @description
  80. * [en]Returns true if running inside Cordova.[/en]
  81. * [ja]Cordovaで実行されているかどうかを返すメソッドです。[/ja]
  82. */
  83. ons.isWebView = ons.platform.isWebView;
  84. /**
  85. * @method ready
  86. * @signature ready(callback)
  87. * @description
  88. * [ja]アプリの初期化に利用するメソッドです。渡された関数は、Onsen UIの初期化が終了している時点で必ず呼ばれます。[/ja]
  89. * [en]Method used to wait for app initialization. Waits for `DOMContentLoaded` and `deviceready`, when necessary, before executing the callback.[/en]
  90. * @param {Function} callback
  91. * [en]Function that executes after Onsen UI has been initialized.[/en]
  92. * [ja]Onsen UIが初期化が完了した後に呼び出される関数オブジェクトを指定します。[/ja]
  93. */
  94. ons.ready = function (callback) {
  95. if (ons.isReady()) {
  96. callback();
  97. } else {
  98. ons._readyLock.waitUnlock(callback);
  99. }
  100. };
  101. /**
  102. * @method setDefaultDeviceBackButtonListener
  103. * @signature setDefaultDeviceBackButtonListener(listener)
  104. * @param {Function} listener
  105. * [en]Function that executes when device back button is pressed. Must be called on `ons.ready`.[/en]
  106. * [ja]デバイスのバックボタンが押された時に実行される関数オブジェクトを指定します。[/ja]
  107. * @description
  108. * [en]Set default handler for device back button.[/en]
  109. * [ja]デバイスのバックボタンのためのデフォルトのハンドラを設定します。[/ja]
  110. */
  111. ons.setDefaultDeviceBackButtonListener = function (listener) {
  112. if (!ons.isReady()) {
  113. readyError(true);
  114. }
  115. ons._defaultDeviceBackButtonHandler.setListener(listener);
  116. };
  117. /**
  118. * @method disableDeviceBackButtonHandler
  119. * @signature disableDeviceBackButtonHandler()
  120. * @description
  121. * [en]Disable device back button event handler. Must be called on `ons.ready`.[/en]
  122. * [ja]デバイスのバックボタンのイベントを受け付けないようにします。[/ja]
  123. */
  124. ons.disableDeviceBackButtonHandler = function () {
  125. if (!ons.isReady()) {
  126. readyError(true);
  127. }
  128. internal.dbbDispatcher.disable();
  129. };
  130. /**
  131. * @method enableDeviceBackButtonHandler
  132. * @signature enableDeviceBackButtonHandler()
  133. * @description
  134. * [en]Enable device back button event handler. Must be called on `ons.ready`.[/en]
  135. * [ja]デバイスのバックボタンのイベントを受け付けるようにします。[/ja]
  136. */
  137. ons.enableDeviceBackButtonHandler = function () {
  138. if (!ons.isReady()) {
  139. readyError(true);
  140. }
  141. internal.dbbDispatcher.enable();
  142. };
  143. ons.fireDeviceBackButtonEvent = function () {
  144. internal.dbbDispatcher.fireDeviceBackButtonEvent();
  145. };
  146. /**
  147. * @method enableAutoStatusBarFill
  148. * @signature enableAutoStatusBarFill()
  149. * @description
  150. * [en]Enable status bar fill feature on iOS7 and above (except for iPhone X). Must be called before `ons.ready`.[/en]
  151. * [ja]iOS7以上(iPhone Xは除く)で、ステータスバー部分の高さを自動的に埋める処理を有効にします。[/ja]
  152. */
  153. ons.enableAutoStatusBarFill = function () {
  154. if (ons.isReady()) {
  155. readyError(false);
  156. }
  157. internal.config.autoStatusBarFill = true;
  158. };
  159. /**
  160. * @method disableAutoStatusBarFill
  161. * @signature disableAutoStatusBarFill()
  162. * @description
  163. * [en]Disable status bar fill feature on iOS7 and above (except for iPhone X). Must be called before `ons.ready`.[/en]
  164. * [ja]iOS7以上(iPhone Xは除く)で、ステータスバー部分の高さを自動的に埋める処理を無効にします。[/ja]
  165. */
  166. ons.disableAutoStatusBarFill = function () {
  167. if (ons.isReady()) {
  168. readyError(false);
  169. }
  170. internal.config.autoStatusBarFill = false;
  171. };
  172. /**
  173. * @method mockStatusBar
  174. * @signature mockStatusBar()
  175. * @description
  176. * [en]Creates a static element similar to iOS status bar. Only useful for browser testing. Must be called before `ons.ready`.[/en]
  177. * [ja][/ja]
  178. */
  179. ons.mockStatusBar = function () {
  180. if (ons.isReady()) {
  181. readyError(false);
  182. }
  183. var mock = function mock() {
  184. if (!document.body.children[0] || !document.body.children[0].classList.contains('ons-status-bar-mock')) {
  185. var android = platform.isAndroid(),
  186. i = function i(_i) {
  187. return '<i class="' + _i.split('-')[0] + ' ' + _i + '"></i>';
  188. };
  189. var left = android ? i('zmdi-twitter') + ' ' + i('zmdi-google-play') : 'No SIM ' + i('fa-wifi'),
  190. center = android ? '' : '12:28 PM',
  191. right = android ? i('zmdi-network') + ' ' + i('zmdi-wifi') + ' ' + i('zmdi-battery') + ' 12:28 PM' : '80% ' + i('fa-battery-three-quarters');
  192. document.body.insertBefore(util.createElement('<div class="ons-status-bar-mock ' + (android ? 'android' : 'ios') + '">' + ('<div>' + left + '</div><div>' + center + '</div><div>' + right + '</div>') + '</div>'), document.body.firstChild);
  193. }
  194. };
  195. document.body ? mock() : internal.waitDOMContentLoaded(mock);
  196. };
  197. /**
  198. * @method disableAnimations
  199. * @signature disableAnimations()
  200. * @description
  201. * [en]Disable all animations. Could be handy for testing and older devices.[/en]
  202. * [ja]アニメーションを全て無効にします。テストの際に便利です。[/ja]
  203. */
  204. ons.disableAnimations = function () {
  205. internal.config.animationsDisabled = true;
  206. };
  207. /**
  208. * @method enableAnimations
  209. * @signature enableAnimations()
  210. * @description
  211. * [en]Enable animations (default).[/en]
  212. * [ja]アニメーションを有効にします。[/ja]
  213. */
  214. ons.enableAnimations = function () {
  215. internal.config.animationsDisabled = false;
  216. };
  217. ons._disableWarnings = function () {
  218. internal.config.warningsDisabled = true;
  219. };
  220. ons._enableWarnings = function () {
  221. internal.config.warningsDisabled = false;
  222. };
  223. /**
  224. * @method disableAutoStyling
  225. * @signature disableAutoStyling()
  226. * @description
  227. * [en]Disable automatic styling.[/en]
  228. * [ja][/ja]
  229. */
  230. ons.disableAutoStyling = autoStyle.disable;
  231. /**
  232. * @method enableAutoStyling
  233. * @signature enableAutoStyling()
  234. * @description
  235. * [en]Enable automatic styling based on OS (default).[/en]
  236. * [ja][/ja]
  237. */
  238. ons.enableAutoStyling = autoStyle.enable;
  239. /**
  240. * @method disableIconAutoPrefix
  241. * @signature disableIconAutoPrefix()
  242. * @description
  243. * [en]Disable adding `fa-` prefix automatically to `ons-icon` classes. Useful when including custom icon packs.[/en]
  244. * [ja][/ja]
  245. */
  246. ons.disableIconAutoPrefix = function () {
  247. util.checkMissingImport('Icon');
  248. elements.Icon.setAutoPrefix(false);
  249. };
  250. /**
  251. * @method forceUIWebViewScrollFix
  252. * @signature forceUIWebViewScrollFix()
  253. * @param {Boolean} force Enable or disable the fix.
  254. * @description
  255. * [en]Applies a fix for iOS UIWebView which prevents scroll events jumping to pages under the top layer. This may visually affect normal scrolling of UIWebView if you open a dialog/menu before the scroll momentum finished. Disabled by default.[/en]
  256. * [ja][/ja]
  257. */
  258. ons.forceUIWebViewScrollFix = function () {
  259. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  260. internal.config.forceUIWebViewScrollFix = force;
  261. };
  262. /**
  263. * @method forcePlatformStyling
  264. * @signature forcePlatformStyling(platform)
  265. * @description
  266. * [en]Refresh styling for the given platform. Only useful for demos. Use `ons.platform.select(...)` instead for development and production.[/en]
  267. * [ja][/ja]
  268. * @param {string} platform New platform to style the elements.
  269. */
  270. ons.forcePlatformStyling = function (newPlatform) {
  271. ons.enableAutoStyling();
  272. ons.platform.select(newPlatform || 'ios');
  273. ons._util.arrayFrom(document.querySelectorAll('*')).forEach(function (element) {
  274. if (element.tagName.toLowerCase() === 'ons-if') {
  275. element._platformUpdate();
  276. } else if (element.tagName.match(/^ons-/i)) {
  277. autoStyle.prepare(element, true);
  278. if (element.tagName.toLowerCase() === 'ons-tabbar') {
  279. element._updatePosition();
  280. }
  281. }
  282. });
  283. };
  284. /**
  285. * @method preload
  286. * @signature preload(templatePaths)
  287. * @param {String|Array} templatePaths
  288. * [en]Set of HTML file paths containing 'ons-page' elements.[/en]
  289. * [ja][/ja]
  290. * @return {Promise}
  291. * [en]Promise that resolves when all the templates are cached.[/en]
  292. * [ja][/ja]
  293. * @description
  294. * [en]Separated files need to be requested on demand and this can slightly delay pushing new pages. This method requests and caches templates for later use.[/en]
  295. * [ja][/ja]
  296. */
  297. ons.preload = function () {
  298. var templates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  299. return _Promise.all((templates instanceof Array ? templates : [templates]).map(function (template) {
  300. if (typeof template !== 'string') {
  301. util.throw('Expected string arguments but got ' + (typeof template === 'undefined' ? 'undefined' : _typeof(template)));
  302. }
  303. return internal.getTemplateHTMLAsync(template);
  304. }));
  305. };
  306. /**
  307. * @method createElement
  308. * @signature createElement(template, options)
  309. * @param {String} template
  310. * [en]Either an HTML file path, a `<template>` id or an HTML string such as `'<div id="foo">hoge</div>'`.[/en]
  311. * [ja][/ja]
  312. * @param {Object} [options]
  313. * [en]Parameter object.[/en]
  314. * [ja]オプションを指定するオブジェクト。[/ja]
  315. * @param {Boolean|HTMLElement} [options.append]
  316. * [en]Whether or not the element should be automatically appended to the DOM. Defaults to `false`. If `true` value is given, `document.body` will be used as the target.[/en]
  317. * [ja][/ja]
  318. * @param {HTMLElement} [options.insertBefore]
  319. * [en]Reference node that becomes the next sibling of the new node (`options.append` element).[/en]
  320. * [ja][/ja]
  321. * @return {HTMLElement|Promise}
  322. * [en]If the provided template was an inline HTML string, it returns the new element. Otherwise, it returns a promise that resolves to the new element.[/en]
  323. * [ja][/ja]
  324. * @description
  325. * [en]Create a new element from a template. Both inline HTML and external files are supported although the return value differs.[/en]
  326. * [ja][/ja]
  327. */
  328. ons.createElement = function (template) {
  329. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  330. template = template.trim();
  331. var create = function create(html) {
  332. var element = ons._util.createElement(html);
  333. element.remove();
  334. if (options.append) {
  335. var target = options.append instanceof HTMLElement ? options.append : document.body;
  336. target.insertBefore(element, options.insertBefore || null);
  337. options.link instanceof Function && options.link(element);
  338. }
  339. return element;
  340. };
  341. return template.charAt(0) === '<' ? create(template) : internal.getPageHTMLAsync(template).then(create);
  342. };
  343. /**
  344. * @method createPopover
  345. * @signature createPopover(page, [options])
  346. * @param {String} page
  347. * [en]Page name. Can be either an HTML file or a <template> containing a <ons-dialog> component.[/en]
  348. * [ja]pageのURLか、もしくは`<template>`で宣言したテンプレートのid属性の値を指定できます。[/ja]
  349. * @param {Object} [options]
  350. * [en]Parameter object.[/en]
  351. * [ja]オプションを指定するオブジェクト。[/ja]
  352. * @param {Object} [options.parentScope]
  353. * [en]Parent scope of the dialog. Used to bind models and access scope methods from the dialog.[/en]
  354. * [ja]ダイアログ内で利用する親スコープを指定します。ダイアログからモデルやスコープのメソッドにアクセスするのに使います。このパラメータはAngularJSバインディングでのみ利用できます。[/ja]
  355. * @return {Promise}
  356. * [en]Promise object that resolves to the popover component object.[/en]
  357. * [ja]ポップオーバーのコンポーネントオブジェクトを解決するPromiseオブジェクトを返します。[/ja]
  358. * @description
  359. * [en]Create a popover instance from a template.[/en]
  360. * [ja]テンプレートからポップオーバーのインスタンスを生成します。[/ja]
  361. */
  362. /**
  363. * @method createDialog
  364. * @signature createDialog(page, [options])
  365. * @param {String} page
  366. * [en]Page name. Can be either an HTML file or an `<template>` containing a <ons-dialog> component.[/en]
  367. * [ja]pageのURLか、もしくは`<template>`で宣言したテンプレートのid属性の値を指定できます。[/ja]
  368. * @param {Object} [options]
  369. * [en]Parameter object.[/en]
  370. * [ja]オプションを指定するオブジェクト。[/ja]
  371. * @return {Promise}
  372. * [en]Promise object that resolves to the dialog component object.[/en]
  373. * [ja]ダイアログのコンポーネントオブジェクトを解決するPromiseオブジェクトを返します。[/ja]
  374. * @description
  375. * [en]Create a dialog instance from a template.[/en]
  376. * [ja]テンプレートからダイアログのインスタンスを生成します。[/ja]
  377. */
  378. /**
  379. * @method createAlertDialog
  380. * @signature createAlertDialog(page, [options])
  381. * @param {String} page
  382. * [en]Page name. Can be either an HTML file or an `<template>` containing a <ons-alert-dialog> component.[/en]
  383. * [ja]pageのURLか、もしくは`<template>`で宣言したテンプレートのid属性の値を指定できます。[/ja]
  384. * @param {Object} [options]
  385. * [en]Parameter object.[/en]
  386. * [ja]オプションを指定するオブジェクト。[/ja]
  387. * @return {Promise}
  388. * [en]Promise object that resolves to the alert dialog component object.[/en]
  389. * [ja]ダイアログのコンポーネントオブジェクトを解決するPromiseオブジェクトを返します。[/ja]
  390. * @description
  391. * [en]Create a alert dialog instance from a template.[/en]
  392. * [ja]テンプレートからアラートダイアログのインスタンスを生成します。[/ja]
  393. */
  394. ons.createPopover = ons.createDialog = ons.createAlertDialog = function (template) {
  395. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  396. return ons.createElement(template, _extends({ append: true }, options));
  397. };
  398. /**
  399. * @method openActionSheet
  400. * @signature openActionSheet(options)
  401. * @description
  402. * [en]Shows an instant Action Sheet and lets the user choose an action.[/en]
  403. * [ja][/ja]
  404. * @param {Object} [options]
  405. * [en]Parameter object.[/en]
  406. * [ja]オプションを指定するオブジェクト。[/ja]
  407. * @param {Array} [options.buttons]
  408. * [en]Represent each button of the action sheet following the specified order. Every item can be either a string label or an object containing `label`, `icon` and `modifier` properties.[/en]
  409. * [ja][/ja]
  410. * @param {String} [options.title]
  411. * [en]Optional title for the action sheet.[/en]
  412. * [ja][/ja]
  413. * @param {Number} [options.destructive]
  414. * [en]Optional index of the "destructive" button (only for iOS). It can be specified in the button array as well.[/en]
  415. * [ja][/ja]
  416. * @param {Boolean} [options.cancelable]
  417. * [en]Whether the action sheet can be canceled by tapping on the background mask or not.[/en]
  418. * [ja][/ja]
  419. * @param {String} [options.modifier]
  420. * [en]Modifier attribute of the action sheet. E.g. `'destructive'`.[/en]
  421. * [ja][/ja]
  422. * @param {String} [options.maskColor]
  423. * [en]Optionally change the background mask color.[/en]
  424. * [ja][/ja]
  425. * @param {String} [options.id]
  426. * [en]The element's id attribute.[/en]
  427. * [ja][/ja]
  428. * @param {String} [options.class]
  429. * [en]The element's class attribute.[/en]
  430. * [ja][/ja]
  431. * @return {Promise}
  432. * [en]Will resolve when the action sheet is closed. The resolve value is either the index of the tapped button or -1 when canceled.[/en]
  433. * [ja][/ja]
  434. */
  435. ons.openActionSheet = actionSheet;
  436. /**
  437. * @method resolveLoadingPlaceholder
  438. * @signature resolveLoadingPlaceholder(page)
  439. * @param {String} page
  440. * [en]Page name. Can be either an HTML file or a `<template>` id.[/en]
  441. * [ja]pageのURLか、もしくは`<template>`で宣言したテンプレートのid属性の値を指定できます。[/ja]
  442. * @description
  443. * [en]If no page is defined for the `ons-loading-placeholder` attribute it will wait for this method being called before loading the page.[/en]
  444. * [ja]ons-loading-placeholderの属性値としてページが指定されていない場合は、ページロード前に呼ばれるons.resolveLoadingPlaceholder処理が行われるまで表示されません。[/ja]
  445. */
  446. ons.resolveLoadingPlaceholder = function (page, link) {
  447. var elements = ons._util.arrayFrom(window.document.querySelectorAll('[ons-loading-placeholder]'));
  448. if (elements.length === 0) {
  449. util.throw('No ons-loading-placeholder exists');
  450. }
  451. elements.filter(function (element) {
  452. return !element.getAttribute('page');
  453. }).forEach(function (element) {
  454. element.setAttribute('ons-loading-placeholder', page);
  455. ons._resolveLoadingPlaceholder(element, page, link);
  456. });
  457. };
  458. ons._setupLoadingPlaceHolders = function () {
  459. ons.ready(function () {
  460. var elements = ons._util.arrayFrom(window.document.querySelectorAll('[ons-loading-placeholder]'));
  461. elements.forEach(function (element) {
  462. var page = element.getAttribute('ons-loading-placeholder');
  463. if (typeof page === 'string') {
  464. ons._resolveLoadingPlaceholder(element, page);
  465. }
  466. });
  467. });
  468. };
  469. ons._resolveLoadingPlaceholder = function (parent, page) {
  470. var link = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function (el, done) {
  471. return done();
  472. };
  473. page && ons.createElement(page).then(function (element) {
  474. element.style.display = 'none';
  475. parent.appendChild(element);
  476. link(element, function () {
  477. while (parent.firstChild && parent.firstChild !== element) {
  478. parent.removeChild(parent.firstChild);
  479. }
  480. element.style.display = '';
  481. });
  482. }).catch(function (error) {
  483. return _Promise.reject('Unabled to resolve placeholder: ' + error);
  484. });
  485. };
  486. function waitDeviceReady() {
  487. var unlockDeviceReady = ons._readyLock.lock();
  488. window.addEventListener('DOMContentLoaded', function () {
  489. if (ons.isWebView()) {
  490. window.document.addEventListener('deviceready', unlockDeviceReady, false);
  491. } else {
  492. unlockDeviceReady();
  493. }
  494. }, false);
  495. }
  496. /**
  497. * @method getScriptPage
  498. * @signature getScriptPage()
  499. * @description
  500. * [en]Access the last created page from the current `script` scope. Only works inside `<script></script>` tags that are direct children of `ons-page` element. Use this to add lifecycle hooks to a page.[/en]
  501. * [ja][/ja]
  502. * @return {HTMLElement}
  503. * [en]Returns the corresponding page element.[/en]
  504. * [ja][/ja]
  505. */
  506. var getCS = 'currentScript' in document ? function () {
  507. return document.currentScript;
  508. } : function () {
  509. return document.scripts[document.scripts.length - 1];
  510. };
  511. ons.getScriptPage = function () {
  512. return getCS() && /ons-page/i.test(getCS().parentElement.tagName) && getCS().parentElement || null;
  513. };
  514. export default ons;