* [html5] add meta.setViewport.
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/214c6e33 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/214c6e33 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/214c6e33 Branch: refs/heads/master Commit: 214c6e33d15dae42a415b6c3f5e2ac2dc2f6301b Parents: 77ab0f8 Author: MrRaindrop <tekk...@gmail.com> Authored: Mon Aug 21 14:35:12 2017 +0800 Committer: MrRaindrop <tekk...@gmail.com> Committed: Mon Aug 21 14:35:12 2017 +0800 ---------------------------------------------------------------------- html5/render/vue/env/weex.js | 21 +++++++++++++++ html5/render/vue/modules/index.js | 4 ++- html5/render/vue/modules/meta.js | 36 +++++++++++++++++++++++++ packages/weex-vue-render/src/index.core.js | 3 +++ 4 files changed, 63 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/214c6e33/html5/render/vue/env/weex.js ---------------------------------------------------------------------- diff --git a/html5/render/vue/env/weex.js b/html5/render/vue/env/weex.js index 199e8ae..7d88268 100644 --- a/html5/render/vue/env/weex.js +++ b/html5/render/vue/env/weex.js @@ -47,6 +47,27 @@ const weex = { return this.registerApiModule(...args) }, + support (feature = '') { + const match = (feature + '').match(/@(component|module)\/(\w+)(.\w+)?/) + if (match) { + const type = match[1] + const mod = match[2] + let method = match[3] + method = method && method.replace(/^\./, '') + switch (type) { + case 'component': + return !!this._components[mod] + case 'module': + const module = this.requireModule(mod) + return module && method ? !!module[method] : !!module + } + } + else { + console.warn(`[vue-render] invalid argument for weex.support: ${feature}`) + return null + } + }, + /** * Register a new vue instance in this weex instance. Put its root element into weex.document.body.children, so * that user can use weex.document.body to walk through all dom structures in all vue instances in the page. http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/214c6e33/html5/render/vue/modules/index.js ---------------------------------------------------------------------- diff --git a/html5/render/vue/modules/index.js b/html5/render/vue/modules/index.js index c0e2fc1..48d1136 100644 --- a/html5/render/vue/modules/index.js +++ b/html5/render/vue/modules/index.js @@ -33,6 +33,7 @@ import modal from './modal' import navigatorModule from './navigator' import webview from './webview' import websocket from './websocket' +import meta from './meta' export default [ geolocation, @@ -46,5 +47,6 @@ export default [ dom, globalEvent, navigatorModule, - webview + webview, + meta ] http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/214c6e33/html5/render/vue/modules/meta.js ---------------------------------------------------------------------- diff --git a/html5/render/vue/modules/meta.js b/html5/render/vue/modules/meta.js new file mode 100644 index 0000000..ed5f0ff --- /dev/null +++ b/html5/render/vue/modules/meta.js @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +const meta = { + /** + * setViewport + * Changing viewport width at runtime is not supported. Please use weex-viewport meta + * tag to specify your viewport in your html file. + */ + setViewport (options) { + console.warn(`[vue-render] meta.setViewport doesn't works as expected in web platform.` + + ` Please use <meta name="weex-viewport" content="xxx"> to specify your viewport width.`) + } +} + +export default { + init (weex) { + weex.registerModule('meta', meta) + } +} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/214c6e33/packages/weex-vue-render/src/index.core.js ---------------------------------------------------------------------- diff --git a/packages/weex-vue-render/src/index.core.js b/packages/weex-vue-render/src/index.core.js index dc49562..5e84c86 100644 --- a/packages/weex-vue-render/src/index.core.js +++ b/packages/weex-vue-render/src/index.core.js @@ -5,6 +5,8 @@ import text from '../../../html5/render/vue/components/text' import image from '../../../html5/render/vue/components/image' import scrollable from '../../../html5/render/vue/components/scrollable' +import meta from '../../../html5/render/vue/modules/meta' + const preInit = weex.init weex.init = function () { @@ -13,6 +15,7 @@ weex.init = function () { weex.install(text) weex.install(image) weex.install(scrollable) + weex.install(meta) } if (global.Vue) {