You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ha...@apache.org on 2017/12/28 05:27:05 UTC
[08/20] incubator-weex git commit: [WEEX-181] rm web renderer codes
and scripts (resolve #958)
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/browser/index.js
----------------------------------------------------------------------
diff --git a/html5/render/browser/index.js b/html5/render/browser/index.js
deleted file mode 100644
index 305d76f..0000000
--- a/html5/render/browser/index.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.
- */
-'use strict'
-
-import Weex from './render/index'
-
-import root from './base/root'
-import div from './base/div'
-import droot from './base/droot'
-
-// install the extended apis and components.
-import extensions from './extend'
-
-Weex.install(root)
-Weex.install(div)
-Weex.install(droot)
-
-Weex.install(extensions)
-
-global.registerComponents([
- { type: 'input', methods: ['focus', 'blur'] }
-])
-
-export default Weex
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/browser/render/config.js
----------------------------------------------------------------------
diff --git a/html5/render/browser/render/config.js b/html5/render/browser/render/config.js
deleted file mode 100644
index e407ef0..0000000
--- a/html5/render/browser/render/config.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.
- */
-'use strict'
-
-const config = {
- weexVersion: '0.5.0',
- debug: false,
- validRoots: ['div', 'list', 'vlist', 'scroller'],
- downgrade: {
- // root: true
- }
-}
-
-export default config
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/browser/render/gesture.js
----------------------------------------------------------------------
diff --git a/html5/render/browser/render/gesture.js b/html5/render/browser/render/gesture.js
deleted file mode 100644
index 24ef581..0000000
--- a/html5/render/browser/render/gesture.js
+++ /dev/null
@@ -1,511 +0,0 @@
-/*
- * 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.
- */
-/* eslint-disable */
-
-'use strict'
-
-var isInitialized = false
-
-// major events supported:
-// panstart
-// panmove
-// panend
-// swipe
-// longpress
-// extra events supported:
-// dualtouchstart
-// dualtouch
-// dualtouchend
-// tap
-// doubletap
-// pressend
-
-var doc = window.document
-var docEl = doc.documentElement
-var slice = Array.prototype.slice
-var gestures = {}
-var lastTap = null
-
-/**
- * find the closest common ancestor
- * if there's no one, return null
- *
- * @param {Element} el1 first element
- * @param {Element} el2 second element
- * @return {Element} common ancestor
- */
-function getCommonAncestor(el1, el2) {
- var el = el1
- while (el) {
- if (el.contains(el2) || el == el2) {
- return el
- }
- el = el.parentNode
- }
- return null
-}
-
-/**
- * fire a HTMLEvent
- *
- * @param {Element} element which element to fire a event on
- * @param {string} type type of event
- * @param {object} extra extra data for the event object
- */
-function fireEvent(element, type, extra) {
- var event = doc.createEvent('HTMLEvents')
- event.initEvent(type, true, true)
-
- if (typeof extra === 'object') {
- for (var p in extra) {
- event[p] = extra[p]
- }
- }
-
- element.dispatchEvent(event)
-}
-
-/**
- * calc the transform
- * assume 4 points ABCD on the coordinate system
- * > rotate:angle rotating from AB to CD
- * > scale:scale ratio from AB to CD
- * > translate:translate shift from A to C
- *
- * @param {number} x1 abscissa of A
- * @param {number} y1 ordinate of A
- * @param {number} x2 abscissa of B
- * @param {number} y2 ordinate of B
- * @param {number} x3 abscissa of C
- * @param {number} y3 ordinate of C
- * @param {number} x4 abscissa of D
- * @param {number} y4 ordinate of D
- * @return {object} transform object like
- * {rotate, scale, translate[2], matrix[3][3]}
- */
-function calc(x1, y1, x2, y2, x3, y3, x4, y4) {
- var rotate = Math.atan2(y4 - y3, x4 - x3) - Math.atan2(y2 - y1, x2 - x1)
- var scale = Math.sqrt((Math.pow(y4 - y3, 2)
- + Math.pow(x4 - x3, 2)) / (Math.pow(y2 - y1, 2)
- + Math.pow(x2 - x1, 2)))
- var translate = [
- x3
- - scale * x1 * Math.cos(rotate)
- + scale * y1 * Math.sin(rotate),
- y3
- - scale * y1 * Math.cos(rotate)
- - scale * x1 * Math.sin(rotate)]
-
- return {
- rotate: rotate,
- scale: scale,
- translate: translate,
- matrix: [
- [scale * Math.cos(rotate), -scale * Math.sin(rotate), translate[0]],
- [scale * Math.sin(rotate), scale * Math.cos(rotate), translate[1]],
- [0, 0, 1]
- ]
- }
-}
-
-/**
- * take over the touchstart events. Add new touches to the gestures.
- * If there is no previous records, then bind touchmove, tochend
- * and touchcancel events.
- * new touches initialized with state 'tapping', and within 500 milliseconds
- * if the state is still tapping, then trigger gesture 'press'.
- * If there are two touche points, then the 'dualtouchstart' is triggerd. The
- * node of the touch gesture is their cloest common ancestor.
- *
- * @event
- * @param {event} event
- */
-function touchstartHandler(event) {
-
- if (Object.keys(gestures).length === 0) {
- docEl.addEventListener('touchmove', touchmoveHandler, false)
- docEl.addEventListener('touchend', touchendHandler, false)
- docEl.addEventListener('touchcancel', touchcancelHandler, false)
- }
-
- // record every touch
- for (var i = 0; i < event.changedTouches.length; i++) {
- var touch = event.changedTouches[i]
- var touchRecord = {}
-
- for (var p in touch) {
- touchRecord[p] = touch[p]
- }
-
- var gesture = {
- startTouch: touchRecord,
- startTime: Date.now(),
- status: 'tapping',
- element: event.srcElement || event.target,
- pressingHandler: setTimeout(function (element, touch) {
- return function () {
- if (gesture.status === 'tapping') {
- gesture.status = 'pressing'
-
- fireEvent(element, 'longpress', {
- // add touch data for weex
- touch: touch,
- touches: event.touches,
- changedTouches: event.changedTouches,
- touchEvent: event
- })
- }
-
- clearTimeout(gesture.pressingHandler)
- gesture.pressingHandler = null
- }
- }(event.srcElement || event.target, event.changedTouches[i]), 500)
- }
- gestures[touch.identifier] = gesture
- }
-
- if (Object.keys(gestures).length == 2) {
- var elements = []
-
- for (var p in gestures) {
- elements.push(gestures[p].element)
- }
-
- fireEvent(getCommonAncestor(elements[0], elements[1]), 'dualtouchstart', {
- touches: slice.call(event.touches),
- touchEvent: event
- })
- }
-}
-
-/**
- * take over touchmove events, and handle pan and dual related gestures.
- *
- * 1. traverse every touch point:
- * > if 'tapping' and the shift is over 10 pixles, then it's a 'panning'.
- * 2. if there are two touch points, then calc the tranform and trigger
- * 'dualtouch'.
- *
- * @event
- * @param {event} event
- */
-function touchmoveHandler(event) {
- for (var i = 0; i < event.changedTouches.length; i++) {
- var touch = event.changedTouches[i]
- var gesture = gestures[touch.identifier]
-
- if (!gesture) {
- return
- }
-
- if (!gesture.lastTouch) {
- gesture.lastTouch = gesture.startTouch
- }
- if (!gesture.lastTime) {
- gesture.lastTime = gesture.startTime
- }
- if (!gesture.velocityX) {
- gesture.velocityX = 0
- }
- if (!gesture.velocityY) {
- gesture.velocityY = 0
- }
- if (!gesture.duration) {
- gesture.duration = 0
- }
-
- var time = Date.now() - gesture.lastTime
- var vx = (touch.clientX - gesture.lastTouch.clientX) / time
- var vy = (touch.clientY - gesture.lastTouch.clientY) / time
-
- var RECORD_DURATION = 70
- if (time > RECORD_DURATION) {
- time = RECORD_DURATION
- }
- if (gesture.duration + time > RECORD_DURATION) {
- gesture.duration = RECORD_DURATION - time
- }
-
- gesture.velocityX = (gesture.velocityX * gesture.duration + vx * time)
- / (gesture.duration + time)
- gesture.velocityY = (gesture.velocityY * gesture.duration + vy * time)
- / (gesture.duration + time)
- gesture.duration += time
-
- gesture.lastTouch = {}
-
- for (var p in touch) {
- gesture.lastTouch[p] = touch[p]
- }
- gesture.lastTime = Date.now()
-
- var displacementX = touch.clientX - gesture.startTouch.clientX
- var displacementY = touch.clientY - gesture.startTouch.clientY
- var distance = Math.sqrt(Math.pow(displacementX, 2)
- + Math.pow(displacementY, 2))
- var isVertical = !(Math.abs(displacementX) > Math.abs(displacementY))
- var direction = isVertical
- ? displacementY >= 0 ? 'down' : 'up'
- : displacementX >= 0 ? 'right' : 'left'
-
- // magic number 10: moving 10px means pan, not tap
- if ((gesture.status === 'tapping' || gesture.status === 'pressing')
- && distance > 10) {
- gesture.status = 'panning'
- gesture.isVertical = isVertical
- gesture.direction = direction
-
- fireEvent(gesture.element, 'panstart', {
- touch: touch,
- touches: event.touches,
- changedTouches: event.changedTouches,
- touchEvent: event,
- isVertical: gesture.isVertical,
- direction: direction
- })
- }
-
- if (gesture.status === 'panning') {
- gesture.panTime = Date.now()
-
- fireEvent(gesture.element, 'panmove', {
- displacementX: displacementX,
- displacementY: displacementY,
- touch: touch,
- touches: event.touches,
- changedTouches: event.changedTouches,
- touchEvent: event,
- isVertical: gesture.isVertical,
- direction: direction
- })
- }
- }
-
- if (Object.keys(gestures).length == 2) {
- var position = []
- var current = []
- var elements = []
- var transform
-
- for (var i = 0; i < event.touches.length; i++) {
- var touch = event.touches[i]
- var gesture = gestures[touch.identifier]
- position.push([gesture.startTouch.clientX, gesture.startTouch.clientY])
- current.push([touch.clientX, touch.clientY])
- }
-
- for (var p in gestures) {
- elements.push(gestures[p].element)
- }
-
- transform = calc(
- position[0][0],
- position[0][1],
- position[1][0],
- position[1][1],
- current[0][0],
- current[0][1],
- current[1][0],
- current[1][1]
- )
- fireEvent(getCommonAncestor(elements[0], elements[1]), 'dualtouch', {
- transform: transform,
- touches: event.touches,
- touchEvent: event
- })
- }
-}
-
-/**
- * handle touchend event
- *
- * 1. if there are tow touch points, then trigger 'dualtouchend'如
- *
- * 2. traverse every touch piont:
- * > if tapping, then trigger 'tap'.
- * If there is a tap 300 milliseconds before, then it's a 'doubletap'.
- * > if padding, then decide to trigger 'panend' or 'swipe'
- * > if pressing, then trigger 'pressend'.
- *
- * 3. remove listeners.
- *
- * @event
- * @param {event} event
- */
-function touchendHandler(event) {
-
- if (Object.keys(gestures).length == 2) {
- var elements = []
- for (var p in gestures) {
- elements.push(gestures[p].element)
- }
- fireEvent(getCommonAncestor(elements[0], elements[1]), 'dualtouchend', {
- touches: slice.call(event.touches),
- touchEvent: event
- })
- }
-
- for (var i = 0; i < event.changedTouches.length; i++) {
- var touch = event.changedTouches[i]
- var id = touch.identifier
- var gesture = gestures[id]
-
- if (!gesture) {
- continue
- }
-
- if (gesture.pressingHandler) {
- clearTimeout(gesture.pressingHandler)
- gesture.pressingHandler = null
- }
-
- if (gesture.status === 'tapping') {
- gesture.timestamp = Date.now()
- fireEvent(gesture.element, 'tap', {
- touch: touch,
- touchEvent: event
- })
-
- if (lastTap && gesture.timestamp - lastTap.timestamp < 300) {
- fireEvent(gesture.element, 'doubletap', {
- touch: touch,
- touchEvent: event
- })
- }
-
- lastTap = gesture
- }
-
- if (gesture.status === 'panning') {
- var now = Date.now()
- var duration = now - gesture.startTime
- var displacementX = touch.clientX - gesture.startTouch.clientX
- var displacementY = touch.clientY - gesture.startTouch.clientY
-
- var velocity = Math.sqrt(gesture.velocityY * gesture.velocityY
- + gesture.velocityX * gesture.velocityX)
- var isSwipe = velocity > 0.5 && (now - gesture.lastTime) < 100
- var extra = {
- duration: duration,
- isSwipe: isSwipe,
- velocityX: gesture.velocityX,
- velocityY: gesture.velocityY,
- displacementX: displacementX,
- displacementY: displacementY,
- touch: touch,
- touches: event.touches,
- changedTouches: event.changedTouches,
- touchEvent: event,
- isVertical: gesture.isVertical,
- direction: gesture.direction
- }
-
- fireEvent(gesture.element, 'panend', extra)
- if (isSwipe) {
- fireEvent(gesture.element, 'swipe', extra)
- }
- }
-
- if (gesture.status === 'pressing') {
- fireEvent(gesture.element, 'pressend', {
- touch: touch,
- touchEvent: event
- })
- }
-
- delete gestures[id]
- }
-
- if (Object.keys(gestures).length === 0) {
- docEl.removeEventListener('touchmove', touchmoveHandler, false)
- docEl.removeEventListener('touchend', touchendHandler, false)
- docEl.removeEventListener('touchcancel', touchcancelHandler, false)
- }
-}
-
-/**
- * handle touchcancel
- *
- * 1. if there are two touch points, then trigger 'dualtouchend'
- *
- * 2. traverse everty touch point:
- * > if pannnig, then trigger 'panend'
- * > if pressing, then trigger 'pressend'
- *
- * 3. remove listeners
- *
- * @event
- * @param {event} event
- */
-function touchcancelHandler(event) {
-
- if (Object.keys(gestures).length == 2) {
- var elements = []
- for (var p in gestures) {
- elements.push(gestures[p].element)
- }
- fireEvent(getCommonAncestor(elements[0], elements[1]), 'dualtouchend', {
- touches: slice.call(event.touches),
- touchEvent: event
- })
- }
-
- for (var i = 0; i < event.changedTouches.length; i++) {
- var touch = event.changedTouches[i]
- var id = touch.identifier
- var gesture = gestures[id]
-
- if (!gesture) {
- continue
- }
-
- if (gesture.pressingHandler) {
- clearTimeout(gesture.pressingHandler)
- gesture.pressingHandler = null
- }
-
- if (gesture.status === 'panning') {
- fireEvent(gesture.element, 'panend', {
- touch: touch,
- touches: event.touches,
- changedTouches: event.changedTouches,
- touchEvent: event
- })
- }
- if (gesture.status === 'pressing') {
- fireEvent(gesture.element, 'pressend', {
- touch: touch,
- touchEvent: event
- })
- }
- delete gestures[id]
- }
-
- if (Object.keys(gestures).length === 0) {
- docEl.removeEventListener('touchmove', touchmoveHandler, false)
- docEl.removeEventListener('touchend', touchendHandler, false)
- docEl.removeEventListener('touchcancel', touchcancelHandler, false)
- }
-}
-
-if (!isInitialized) {
- docEl.addEventListener('touchstart', touchstartHandler, false)
- isInitialized = true
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/browser/render/index.js
----------------------------------------------------------------------
diff --git a/html5/render/browser/render/index.js b/html5/render/browser/render/index.js
deleted file mode 100644
index f317489..0000000
--- a/html5/render/browser/render/index.js
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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.
- */
-
-/* global lib, WebSocket */
-
-'use strict'
-
-import './style/base.css'
-
-import { subversion } from '../../../../package.json'
-import runtime from '../../../runtime'
-import frameworks from '../../../frameworks'
-
-runtime.config.frameworks = frameworks
-const { framework, transformer } = subversion
-
-// register framework meta info
-global.frameworkVersion = framework
-global.transformerVersion = transformer
-
-// init bridge.
-import { Sender, receiver } from '../bridge'
-receiver.init()
-
-// init frameworks
-import Listener from '../dom/componentManager'
-runtime.config.Document.Listener = Listener
-const globalMethods = runtime.init(runtime.config)
-
-// set global methods
-for (const methodName in globalMethods) {
- global[methodName] = (...args) => {
- const ret = globalMethods[methodName](...args)
- if (ret instanceof Error) {
- console.error(ret.toString())
- }
- return ret
- }
-}
-
-import config from './config'
-import { load } from './loader'
-import * as utils from '../utils'
-import Component from '../base/component'
-import Atomic from '../base/atomic'
-import ComponentManager from '../dom/componentManager'
-import { bind as bindRegister } from './register'
-
-import 'envd'
-import 'httpurl'
-
-// gesture
-import './gesture'
-
-const DEFAULT_DESIGN_WIDTH = 750
-const DEFAULT_ROOT_ID = 'weex'
-const DEFAULT_JSONP_CALLBACK_NAME = 'weexJsonpCallback'
-
-global.WXEnvironment = {
- weexVersion: config.weexVersion,
- appName: lib.env.aliapp ? lib.env.aliapp.appname : null,
- appVersion: lib.env.aliapp ? lib.env.aliapp.version.val : null,
- platform: 'Web',
- osName: lib.env.browser ? lib.env.browser.name : null,
- osVersion: lib.env.browser ? lib.env.browser.version.val : null,
- deviceWidth: window.innerWidth,
- deviceHeight: window.innerHeight,
- devicePixelRatio: window.devicePixelRatio ? window.devicePixelRatio : (window.screen.width >= 1440 ? 3.5 : (window.screen.width >= 1080 ? 3 : (window.screen.width >= 800 ? 2.5 : (window.screen.width >= 640 ? 2 : (window.screen.width >= 480 ? 1.5 : 1)))))
-}
-
-const _weexInstance = {}
-
-function noop () {}
-
-function setupViewport (width) {
- document.querySelector('meta[name=viewport]').setAttribute('content', `width=${width}, user-scalable=no`)
-}
-
-; (function initializeWithUrlParams () {
- // in casperjs the protocol is file.
- if (location.protocol.match(/file/)) {
- return
- }
-
- const params = lib.httpurl(location.href).params
-
- // set global 'debug' config to true if there's a debug flag in current url.
- const debug = params['debug']
- config.debug = debug === true || debug === 'true'
-
- !config.debug && (console.debug = noop)
-
- // config for the 'downgrade'.
- for (const key in params) {
- if (params.hasOwnProperty(key)) {
- const match = key.match(/^downgrade_(\w+)$/)
- if (!match || !match[1]) {
- continue
- }
- const dk = match[1]
- // downgrade in the config file has the highest priority.
- if (typeof config.downgrade[dk] === 'boolean') {
- continue
- }
- const dr = params[`downgrade_${dk}`]
- config.downgrade[dk] = dr === true || dr === 'true'
- }
- }
-})()
-
-export default function Weex (options) {
- if (!(this instanceof Weex)) {
- return new Weex(options)
- }
-
- // Width of the root container. Default is window.innerWidth.
- this.width = options.width || window.innerWidth
- this.bundleUrl = options.bundleUrl || location.href
- this.instanceId = options.appId
- this.rootId = options.rootId || (DEFAULT_ROOT_ID + utils.getRandom(10))
- this.jsonpCallback = options.jsonpCallback || DEFAULT_JSONP_CALLBACK_NAME
- this.source = options.source
- this.loader = options.loader
- this.embed = options.embed
-
- // init viewport
- setupViewport(DEFAULT_DESIGN_WIDTH)
-
- // downgrade options.
- const dg = options.downgrade || []
- dg.forEach(function (comp) {
- config.downgrade[comp] = true
- })
-
- this.data = options.data
- this.sender = new Sender(this)
-
- _weexInstance[this.instanceId] = this
-
- // load bundle.
- load({
- jsonpCallback: this.jsonpCallback,
- source: this.source,
- loader: this.loader
- }, function (err, appCode) {
- if (!err) {
- this.createApp(config, appCode)
- }
- else {
- console.error('load bundle err:', err)
- }
- }.bind(this))
-}
-
-Weex.init = function (options) {
- if (utils.isArray(options)) {
- options.forEach(function (config) {
- new Weex(config)
- })
- }
- else if (utils.getType(options) === 'object') {
- new Weex(options)
- }
-}
-
-Weex.getInstance = function (instanceId) {
- return _weexInstance[instanceId]
-}
-
-Weex.prototype = {
-
- createApp: function (config, appCode) {
- let root = document.querySelector('#' + this.rootId)
- if (!root) {
- root = document.createElement('div')
- root.id = this.rootId
- document.body.appendChild(root)
- }
-
- const instance = window.createInstance(
- this.instanceId,
- appCode,
- {
- bundleUrl: this.bundleUrl,
- debug: config.debug
- },
- this.data
- )
-
- if (instance instanceof Error) {
- return console.error('[h5-render]', instance)
- }
-
- // Do not destroy instance before unload, because in most browser
- // press back button to back to this page will not refresh
- // the window and the instance will not be recreated then.
- // window.addEventListener('beforeunload', function (e) {
- // })
- },
-
- getComponentManager: function () {
- if (!this._componentManager) {
- this._componentManager = ComponentManager.getInstance(this.instanceId)
- }
- return this._componentManager
- },
-
- getRoot: function () {
- return document.querySelector('#' + this.rootId)
- }
-}
-
-Weex.stopTheWorld = function (instanceId) {
- if (!instanceId) {
- return Object.keys(_weexInstance).map(function (instanceId) {
- Weex.stopTheWorld(instanceId)
- })
- }
- window.destroyInstance(instanceId)
-}
-
-// for weex-toolkit.
-; (function startRefreshController () {
- if (location.protocol.match(/file/)) {
- return
- }
- if (location.search.indexOf('hot-reload_controller') === -1) {
- return
- }
- if (typeof WebSocket === 'undefined') {
- console.info('auto refresh need WebSocket support')
- return
- }
- const host = location.hostname
- const port = 8082
- const client = new WebSocket('ws://' + host + ':' + port + '/',
- 'echo-protocol'
- )
- client.onerror = function () {
- console.log('refresh controller websocket connection error')
- }
- client.onmessage = function (e) {
- console.log('Received: \'' + e.data + '\'')
- if (e.data === 'refresh') {
- location.reload()
- }
- }
-})()
-
-bindRegister(Weex)
-
-utils.extend(Weex, {
- Component,
- Atomic,
- ComponentManager,
- utils,
- config
-})
-
-global.weex = Weex
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/browser/render/loader.js
----------------------------------------------------------------------
diff --git a/html5/render/browser/render/loader.js b/html5/render/browser/render/loader.js
deleted file mode 100644
index f05e6ac..0000000
--- a/html5/render/browser/render/loader.js
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.
- */
-
-/* global XMLHttpRequest */
-
-'use strict'
-
-function loadByXHR (config, callback) {
- if (!config.source) {
- callback(new Error('xhr loader: missing config.source.'))
- }
- const xhr = new XMLHttpRequest()
- xhr.open('GET', config.source)
- xhr.onload = function () {
- callback(null, this.responseText)
- }
- xhr.onerror = function (error) {
- callback(error)
- }
- xhr.send()
-}
-
-function loadByJsonp (config, callback) {
- if (!config.source) {
- callback(new Error('jsonp loader: missing config.source.'))
- }
- const callbackName = config.jsonpCallback || 'weexJsonpCallback'
- window[callbackName] = function (code) {
- if (code) {
- callback(null, code)
- }
- else {
- callback(new Error('load by jsonp error'))
- }
- }
- const script = document.createElement('script')
- script.src = decodeURIComponent(config.source)
- script.type = 'text/javascript'
- document.body.appendChild(script)
-}
-
-function loadBySourceCode (config, callback) {
- // src is the jsbundle.
- // no need to fetch from anywhere.
- if (config.source) {
- callback(null, config.source)
- }
- else {
- callback(new Error('source code laoder: missing config.source.'))
- }
-}
-
-const callbackMap = {
- xhr: loadByXHR,
- jsonp: loadByJsonp,
- source: loadBySourceCode
-}
-
-export function load (options, callback) {
- const loadFn = callbackMap[options.loader]
- loadFn(options, callback)
-}
-
-export function registerLoader (name, loaderFunc) {
- if (typeof loaderFunc === 'function') {
- callbackMap[name] = loaderFunc
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/browser/render/register.js
----------------------------------------------------------------------
diff --git a/html5/render/browser/render/register.js b/html5/render/browser/render/register.js
deleted file mode 100644
index ecf71dd..0000000
--- a/html5/render/browser/render/register.js
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.
- */
-import ComponentManager from '../dom/componentManager'
-import { registerLoader } from './loader'
-import { protocol } from '../bridge'
-import { extend } from '../utils'
-import { addEventListener, removeAllEventListeners } from '../base/moduleEvent'
-
-/**
- * register module event listener for every api module except 'globalEvent'.
- */
-function registerModuleEventListener (name, module, meta) {
- if (name !== 'globalEvent') {
- module['addEventListener'] = function (evt, callbackId, options) {
- return addEventListener.call(this, name, evt, callbackId, options)
- }
- module['removeAllEventListeners'] = function (evt) {
- return removeAllEventListeners.call(this, name, evt)
- }
- ; [{
- name: 'addEventListener',
- args: ['string', 'function', 'object']
- }, {
- name: 'removeAllEventListeners',
- args: ['string']
- }].forEach(info => meta[name].push(info))
- }
-}
-
-const methods = {
- // Register a new component with the specified name.
- registerComponent (name, comp) {
- ComponentManager.registerComponent(name, comp)
- },
-
- // Register a new api module.
- // If the module already exists, just add methods from the
- // new module to the old one.
- registerApiModule (name, module, meta) {
- registerModuleEventListener(name, module, meta)
- if (!protocol.apiModule[name]) {
- protocol.apiModule[name] = module
- }
- else {
- for (const key in module) {
- if (module.hasOwnProperty(key)) {
- protocol.apiModule[name][key] = module[key]
- }
- }
- }
- // register API module's meta info to jsframework
- if (meta) {
- protocol.setApiModuleMeta(meta)
- global.registerModules(protocol.getApiModuleMeta(name), true)
- }
- },
-
- // Register a new api method for the specified module.
- // opts:
- // - args: type of arguments the API method takes such
- // as ['string', 'function']
- registerApi (moduleName, name, method, args) {
- if (typeof method !== 'function') {
- return
- }
- if (!protocol.apiModule[moduleName]) {
- protocol.apiModule[moduleName] = {}
- protocol._meta[moduleName] = []
- }
- protocol.apiModule[moduleName][name] = method
- if (!args) {
- return
- }
- // register API meta info to jsframework
- protocol.setApiMeta(moduleName, {
- name: name,
- args: args
- })
- global.registerModules(protocol.getApiModuleMeta(moduleName), true)
- },
-
- // Register a new weex-bundle-loader.
- registerLoader (name, loaderFunc) {
- registerLoader(name, loaderFunc)
- }
-
-}
-
-// To install components and plugins.
-function install (mod) {
- mod.init(this)
-}
-
-export function bind (Weex) {
- Weex.install = install.bind(Weex)
- extend(Weex, methods)
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/browser/render/style/base.css
----------------------------------------------------------------------
diff --git a/html5/render/browser/render/style/base.css b/html5/render/browser/render/style/base.css
deleted file mode 100644
index ebfd0c0..0000000
--- a/html5/render/browser/render/style/base.css
+++ /dev/null
@@ -1,48 +0,0 @@
-* {
- margin: 0;
- padding: 0;
- text-size-adjust: none;
-}
-
-ul, ol {
- list-style: none;
-}
-
-.weex-container {
- box-sizing: border-box;
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- -webkit-box-orient: vertical;
- -webkit-flex-direction: column;
- flex-direction: column;
- -webkit-flex-shrink: 0;
- flex-shrink: 0;
- -webkit-flex-grow: 0;
- flex-grow: 0;
- -webkit-flex-basis: auto;
- flex-basis: auto;
- align-items: stretch;
- box-align: stretch;
- align-content: flex-start;
- position: relative;
- border: 0 solid black;
- margin: 0;
- padding: 0;
- min-width: 0;
-}
-
-.weex-element {
- box-sizing: border-box;
- position: relative;
- -webkit-flex-shrink: 0;
- flex-shrink: 0;
- -webkit-flex-grow: 0;
- flex-grow: 0;
- -webkit-flex-basis: auto;
- flex-basis: auto;
- border: 0 solid black;
- margin: 0;
- padding: 0;
- min-width: 0;
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/browser/utils/array.js
----------------------------------------------------------------------
diff --git a/html5/render/browser/utils/array.js b/html5/render/browser/utils/array.js
deleted file mode 100644
index 3c12611..0000000
--- a/html5/render/browser/utils/array.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.
- */
-'use strict'
-
-export function isArray (arr) {
- return Array.isArray
- ? Array.isArray(arr)
- : (Object.prototype.toString.call(arr) === '[object Array]')
-}
-
-export function slice (arr, start, end) {
- if (isArray(arr)) {
- return arr.slice(start, end)
- }
- const slice = Array.prototype.slice
- return slice.call(arr, start, end)
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/browser/utils/index.js
----------------------------------------------------------------------
diff --git a/html5/render/browser/utils/index.js b/html5/render/browser/utils/index.js
deleted file mode 100644
index 57ec1ab..0000000
--- a/html5/render/browser/utils/index.js
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * 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.
- */
-
-/* global Image */
-
-'use strict'
-
-// const WEAPP_STYLE_ID = 'weapp-style'
-
-import '../../../shared/objectAssign'
-
-export {
- extend,
- def,
- remove,
- hasOwn,
- bind,
- toArray,
- isObject,
- isPlainObject,
- typof
-} from '../../../frameworks/legacy/util'
-
-import { isArray, slice } from './array'
-export { isArray, slice }
-
-export const vendors = ['ms', 'moz', 'webkit', 'o']
-
-let _isWebpSupported = false
-
-; (function isSupportWebp () {
- try {
- const webP = new Image()
- webP.src = 'data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdA'
- + 'SoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA'
- webP.onload = function () {
- if (webP.height === 2) {
- _isWebpSupported = true
- }
- }
- }
- catch (e) {
- // do nothing.
- }
-})()
-
-let _isStickySupported = false
-
-; (function isSupportSticky () {
- const element = document.createElement('div')
- const elementStyle = element.style
- elementStyle.cssText = vendors.concat(['']).map(function (vendor) {
- return 'position:'
- + (vendor ? '-' + vendor + '-' : '')
- + 'sticky'
- }).join(';') + ';'
- _isStickySupported = elementStyle.position.indexOf('sticky') !== -1
-})()
-
-// export function extend (to, from) {
-// for (const key in from) {
-// to[key] = from[key]
-// }
-// return to
-// }
-
-// export function isPlainObject (obj) {
-// return Object.prototype.toString.call(obj)
-// .slice(8, -1).toLowerCase() === 'object'
-// }
-
-export function getType (obj) {
- return Object.prototype.toString.call(obj)
- .slice(8, -1).toLowerCase()
-}
-
-export function appendStyle (css, styleId, replace) {
- let style = document.getElementById(styleId)
- if (style && replace) {
- style.parentNode.removeChild(style)
- style = null
- }
- if (!style) {
- style = document.createElement('style')
- style.type = 'text/css'
- styleId && (style.id = styleId)
- document.getElementsByTagName('head')[0].appendChild(style)
- }
- style.appendChild(document.createTextNode(css))
-}
-
-export function getUniqueFromArray (arr) {
- if (!isArray(arr)) {
- return []
- }
- const res = []
- const unique = {}
- let val
- for (let i = 0, l = arr.length; i < l; i++) {
- val = arr[i]
- if (unique[val]) {
- continue
- }
- unique[val] = true
- res.push(val)
- }
- return res
-}
-
-export function detectWebp () {
- return _isWebpSupported
-}
-
-export function detectSticky () {
- return _isStickySupported
-}
-
-export function getRandom (num) {
- const _defaultNum = 10
- if (typeof num !== 'number' || num <= 0) {
- num = _defaultNum
- }
- const _max = Math.pow(10, num)
- return Math.floor(Date.now() + Math.random() * _max) % _max
-}
-
-export function getRgb (color) {
- let match
- color = color + ''
- match = color.match(/#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})/)
- if (match) {
- return {
- r: parseInt(match[1], 16),
- g: parseInt(match[2], 16),
- b: parseInt(match[3], 16)
- }
- }
- match = color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/)
- if (match) {
- return {
- r: parseInt(match[1]),
- g: parseInt(match[2]),
- b: parseInt(match[3])
- }
- }
-}
-
-// direction: 'l' | 'r', default is 'r'
-// num: how many times to loop, should be a positive integer
-export function loopArray (arr, num, direction) {
- if (!isArray(arr)) {
- return
- }
- let isLeft = (direction + '').toLowerCase() === 'l'
- const len = arr.length
- num = num % len
- if (num < 0) {
- num = -num
- isLeft = !isLeft
- }
- if (num === 0) {
- return arr
- }
- let lp, rp
- if (isLeft) {
- lp = arr.slice(0, num)
- rp = arr.slice(num)
- }
- else {
- lp = arr.slice(0, len - num)
- rp = arr.slice(len - num)
- }
- return rp.concat(lp)
-}
-
-export function throttle (func, wait) {
- let result
- let timerId = null
- let previous = 0
- let context
- let args
- const later = function () {
- previous = Date.now()
- timerId = null
- result = func.apply(context, args)
- }
- return function () {
- const now = Date.now()
- const remaining = wait - (now - previous)
- context = this
- args = Array.prototype.slice.call(arguments)
- if (remaining <= 0) {
- clearTimeout(timerId)
- timerId = null
- previous = now
- result = func.apply(context, args)
- }
- else if (!timerId) {
- timerId = setTimeout(later, remaining)
- }
- return result
- }
-}
-
-export function camelToKebab (name) {
- if (!name) { return '' }
- return name.replace(/([A-Z])/g, function (g, g1) {
- return `-${g1.toLowerCase()}`
- })
-}
-
-export function kebabToCamel (name) {
- if (!name) { return '' }
- return name.replace(/-([a-z])/g, function (g, g1) {
- console.log(g1)
- return `${g1.toUpperCase()}`
- })
-}
-
-export function findEnterKeyType (key) {
- const keys = ['default', 'go', 'next', 'search', 'send']
- if (keys.indexOf(key) > -1) {
- return key
- }
- return 'done'
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/browser/utils/logger.js
----------------------------------------------------------------------
diff --git a/html5/render/browser/utils/logger.js b/html5/render/browser/utils/logger.js
deleted file mode 100644
index 3ae2ff4..0000000
--- a/html5/render/browser/utils/logger.js
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.
- */
-
-// let _initialized = false
-
-// export default logger = {
-// log: function () {},
-// warn: function () {},
-// error: function () {}
-// }
-
-// function hijack (k) {
-// if (utils.isArray(k)) {
-// k.forEach(function (key) {
-// hijack(key)
-// })
-// }
-// else {
-// if (console[k]) {
-// logger[k] = function () {
-// console[k].apply(
-// console,
-// ['[h5-render]'].concat(Array.prototype.slice.call(arguments, 0))
-// )
-// }
-// }
-// }
-// }
-
-// logger.init = function () {
-// if (_initialized) {
-// return
-// }
-// _initialized = true
-// if (config.debug && console) {
-// hijack(['log', 'warn', 'error'])
-// }
-// }
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/.eslintrc
----------------------------------------------------------------------
diff --git a/html5/render/vue/.eslintrc b/html5/render/vue/.eslintrc
deleted file mode 100644
index e5a34ae..0000000
--- a/html5/render/vue/.eslintrc
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "env": {
- "browser": true
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/README.md
----------------------------------------------------------------------
diff --git a/html5/render/vue/README.md b/html5/render/vue/README.md
index feddee8..a8bf32e 100644
--- a/html5/render/vue/README.md
+++ b/html5/render/vue/README.md
@@ -1,230 +1,3 @@
-# Vue Web Renderer for Weex
+# weex-vue-render
-This is a group of Vue 2.x components for Weex, which have the same behavior with the Weex built-in components on the native.
-
-It can be run on browser only based on Vue 2.x (without Weex).
-
-## how to use
-
-If you prefer npm way, you should manually call `init` function to pass Vue constructor to weex.
-
-```javascript
-import Vue from 'vue'
-import weex from 'weex-vue-render'
-weex.init(Vue)
-
-import App from 'App.vue'
-new Vue(App)
-```
-
-If you perfer cdn way, and use script tag to import a script link, just import it into your html file, it will auto-init and you can just ignore it.
-
-```html
-<script>{{Vue}}</script>
-<script>{{weex-vue-render}}</script>
-<script>{{your js bundle}}</script>
-```
-
-## use render-core and plugins
-
-You can juse use a **render-core** in your page, and define your needs for the plugins (components and API modules) in your entry file, so that your would save a lot of bundle size and bandwidth. On the other hand, The full version contains all the built-in components and API modules, which will waste a lot of bundle size and bandwidth if you haven't use most of them.
-
-To use the render-core and the plugins, just install the plugins in your entry file.
-
-```javascript
-import Vue from 'vue'
-
-// import render-core.
-import weex from 'weex-vue-render/dist/index.core'
-
-// import the plugins (components and modules) you want to use.
-import slider from 'weex-vue-slider'
-import stream from 'weex-vue-stream'
-
-// init weex.
-weex.init(Vue)
-
-// install the plugins.
-weex.install(slider)
-weex.install(stream)
-
-import App from 'App.vue'
-new Vue(App)
-```
-
-#### built-in components in render-core
-
-These components have already integrated into render-core. You don't have to import and install them:
-
-* div
-* text
-* image
-* scrollable components (scroller, list, waterfall)
-
-#### available built-in components for you to install
-
-| npm module name | component name |
-| --- | --- |
-| weex-vue-a | a |
-| weex-vue-input | input |
-| weex-vue-slider | slider / slider-neighbor |
-| weex-vue-switch | switch |
-| weex-vue-textarea | textarea |
-| weex-vue-video | video |
-| weex-vue-web | web |
-
-#### available API modules for you to install
-
-| npm module name | API module name |
-| --- | --- |
-| weex-vue-animation | animation |
-| weex-vue-clipboard | clipboard |
-| weex-vue-dom | dom |
-| weex-vue-event | event |
-| weex-vue-geolocation | geolocation |
-| weex-vue-global-event | globalEvent |
-| weex-vue-modal | modal |
-| weex-vue-nav | navigator |
-| weex-vue-storage | storage |
-| weex-vue-stream | stream |
-| weex-vue-websocket | websocket |
-| weex-vue-webview | webview |
-
-Some of the above plugins may not be mentioned in weex documents. Just ignore them if you have no idear about what they are and how to use them.
-
-You can develop more plugins for your app. Accordingly the same plugin for other two platforms (iOS and Android) should also be built and intergrated in your app if you want it run on all three platforms.
-
-#### scan your code
-
-Use `weex-vue-bundle-util` to scan you code, which will return a promise with a object to tell which components and modules you have used in your project, so that can generate a entry file accordingly to import those plugins.
-
-https://github.com/weexteam/weex-vue-bundle-util
-
-You can see the examples of weex built in this way by running the script `npm run build:vue:examples`, and use the `<script src="./dist/render.vue.js"></script>` as the render in the `vue.html` file.
-
-## use vue-loader to bundle .vue file
-
-NOTE: you should inject `$processStyle` to preprocess vnode's style in vue-loader's postTransformNode hook.
-
-```javascript
-vue: {
- /**
- * important! should use postTransformNode to add $processStyle for
- * inline style prefixing.
- */
- compilerModules: [
- {
- postTransformNode: el => {
- el.staticStyle = `$processStyle(${el.staticStyle})`
- el.styleBinding = `$processStyle(${el.styleBinding})`
- }
- }
- ],
-}
-```
-
-## changelog
-
-#### 0.12.1
-
-* pack a core sdk for weex-vue-render into `weex-vue-render/dist/index.core.js`.
-* pack modules and components into npm packages, and make them able to install.
-
-#### 0.12.3
-
-* support component method `image.save` for `<image>` component.
-* distinguish gesture events with the same named events generated elsewhere.
-* fix fast click event.
-* fix `modal.toast` on android.
-* fix css prefixer for gradients.
-
-#### 0.12.4
-
-* fix scanning style in production with uglified code.
-
-#### 0.12.8
-
-* optimize event binding.
-* fix a-jump interception condition.
-
-#### 0.12.9
-
-* event handling ignore none-vue element.
-
-#### 0.12.10
-
-* fix accessing vm in dom which is not a vue component.
-
-#### 0.12.11
-
-* fix styles in firefox.
-* implement methods about selection range.
-
-#### 0.12.12
-
-* fix NS (svg) bug in vue.js@v2.4.3
-
-#### 0.12.13
-
-* reset `env.deviceHeight` after window's resizing.
-
-#### 0.12.14
-
-* fix loading & refresh: pulling down wrongly triggered.
-
-#### 0.12.16
-
-* not to prevent default behaviour of click events unless the click-binding element is inside a `<a>` link, or it is a `<a>` link and has a `prevent` attribute on it.
-
-#### 0.12.18
-
-* support offset appear.
-* fix lazyload failing when frequently updating images' src. Typical scenario is skeleton replacing.
-
-#### 0.12.20
-
-* fix scrollToElement on latest chrome.
-
-#### 0.12.21
-
-* fix `stream.fetch` for adding wrong suffix to the request url.
-
-#### 0.12.22
-
-* fix image lazyloading.
-
-#### 0.12.24
-
-* add try catch to accessing localStorage.
-* support image sprite.
-
-#### 0.12.25
-
-* fix indicator position in one page slider.
-
-#### 0.12.26
-
-* fix unit wx, which is a straight px value not to adapt to screens.
-
-## component -> dom map
-
-| component | dom element | children | note |
-| --- | --- | ---- | --- |
-| scroller | /main | /main/div/x | - |
-| list | /main | /main/div/x | - |
-| cell | /sect | /sect/x | - |
-| header | /head | /head/x | - |
-| loading | /asid | /aside/x | - |
-| loading-indicator | /mark | /mark/x | - |
-| refresh | /asid | /aside/x | - |
-| slider | /nav | x -> /ul/li/x, indicator -> /nav/nav | - |
-| indicator | /nav | - | indicator points: /nav/mark |
-| a | /a | /a/x | - |
-| div | /div | /div/x | - |
-| image | /figure | - | - |
-| input | /input | - | - |
-| switch | /span | - | round button: /span/small |
-| text | /p | - | - |
-| textarea | /textarea | - | - |
-| video | /video | - | - |
-| web | /iframe | - | - |
+This project has been moved to [weexteam group](https://github.com/weexteam/weex-vue-render)
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/components/a.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/a.js b/html5/render/vue/components/a.js
deleted file mode 100644
index 2915952..0000000
--- a/html5/render/vue/components/a.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.
- */
-// import { validateStyles } from '../validator'
-
-const _css = `
-.weex-a {
- text-decoration: none;
-}
-`
-
-function getA (weex) {
- const {
- extractComponentStyle,
- trimTextVNodes
- } = weex
-
- return {
- name: 'weex-a',
- props: {
- href: String
- },
- render (createElement) {
- /* istanbul ignore next */
- // if (process.env.NODE_ENV === 'development') {
- // validateStyles('a', this.$vnode.data && this.$vnode.data.staticStyle)
- // }
- return createElement('html:a', {
- attrs: {
- 'weex-type': 'a',
- href: this.href
- },
- staticClass: 'weex-a weex-ct',
- staticStyle: extractComponentStyle(this)
- }, trimTextVNodes(this.$slots.default))
- },
- _css
- }
-}
-
-export default {
- init (weex) {
- weex.registerComponent('a', getA(weex))
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/components/div.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/div.js b/html5/render/vue/components/div.js
deleted file mode 100644
index 8b29a70..0000000
--- a/html5/render/vue/components/div.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 _css = `
-body > .weex-div {
- min-height: 100%;
-}
-`
-
-function getDiv (weex) {
- const {
- extractComponentStyle,
- trimTextVNodes
- } = weex
-
- return {
- name: 'weex-div',
- render (createElement) {
- return createElement('html:div', {
- attrs: { 'weex-type': 'div' },
- staticClass: 'weex-div weex-ct',
- staticStyle: extractComponentStyle(this)
- }, trimTextVNodes(this.$slots.default))
- },
- _css
- }
-}
-
-export default {
- init (weex) {
- const div = getDiv(weex)
- weex.registerComponent('div', div)
- weex.registerComponent('container', div)
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/components/image.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/image.js b/html5/render/vue/components/image.js
deleted file mode 100644
index d2041e2..0000000
--- a/html5/render/vue/components/image.js
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * 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.
- */
-
-let extractComponentStyle, createEventMap, extend, isArray
-
-const IMG_NAME_BITS = 15
-
-const _css = `
-.weex-image, .weex-img {
- background-repeat: no-repeat;
- background-position: 50% 50%;
-}
-`
-/**
- * 1. get sprite style if spritePosition is set.
- * 2. else get resize (stetch|cover|contain) related styles.
- */
-function getCustomStyle (context, mergedStyle) {
- let spritePosition = context.spritePosition
- if (spritePosition && !isArray(spritePosition)) {
- spritePosition = (spritePosition + '').split(',').map(function (val) {
- return val.replace(/[[\]]/g, '').replace(/^\s*(\S[\s\S]*?)\s*$/g, function ($0, $1) {
- return parseInt($1)
- })
- })
- }
- if (spritePosition) {
- const posX = -spritePosition[0]
- const posY = -spritePosition[1]
- const scale = weex.config.env.scale
- const sizeScale = parseFloat(context.spriteWidth) / parseFloat(mergedStyle.width) * weex.config.env.scale
- return {
- 'background-position': `${posX * scale}px ${posY * scale}px`,
- 'background-size': `${sizeScale * 100}%`
- }
- }
- const stretch = '100% 100%'
- const resize = context.resize || stretch
- const bgSize = ['cover', 'contain', stretch].indexOf(resize) > -1 ? resize : stretch
- // compatibility: http://caniuse.com/#search=background-size
- return { 'background-size': bgSize }
-}
-
-function preProcessSrc (context, url, mergedStyle) {
- // somehow the merged style in _prerender hook is gone.
- // just return the original src.
- if (!mergedStyle || !mergedStyle.width || !mergedStyle.height) {
- return url
- }
- const { width, height } = mergedStyle
- return context.processImgSrc && context.processImgSrc(url, {
- width: parseFloat(width),
- height: parseFloat(height),
- quality: context.quality,
- sharpen: context.sharpen,
- original: context.original
- }) || url
-}
-
-function download (url, callback) {
- function success () {
- callback && callback({
- success: true
- })
- }
- function fail (err) {
- callback && callback({
- success: false,
- errorDesc: err + ''
- })
- }
- try {
- let isDataUrl = false
- let parts
- let name
- if (url.match(/data:image\/[^;]+;base64,/)) {
- isDataUrl = true
- parts = url.split(',')
- }
- if (!isDataUrl) {
- name = url
- .replace(/\?[^?]+/, '')
- .replace(/#[^#]+/, '')
- .match(/([^/]+)$/)
- }
- else {
- name = parts[1].substr(0, IMG_NAME_BITS)
- }
- const aEl = document.createElement('a')
- aEl.href = url
- /**
- * Not all browser support this 'download' attribute. In these browsers it'll jump
- * to the photo url page and user have to longpress the photo to save it.
- */
- aEl.download = name
- const clickEvt = new Event('click', { bubbles: false })
- aEl.dispatchEvent(clickEvt)
- success()
- }
- catch (err) {
- fail(err)
- }
-}
-
-const image = {
- name: 'weex-image',
- props: {
- src: String,
- placeholder: String,
- resize: String,
- quality: String,
- sharpen: String,
- original: [String, Boolean],
- spriteSrc: String,
- spritePosition: [String, Array],
- spriteWidth: [String, Number]
- },
-
- updated () {
- this._fireLazyload()
- },
-
- mounted () {
- this._fireLazyload()
- },
-
- methods: {
- save (callback) {
- download(this.src, callback)
- }
- },
-
- render (createElement) {
- const style = extractComponentStyle(this)
- const customStyle = getCustomStyle(this, style)
- return createElement('figure', {
- attrs: {
- 'weex-type': 'image',
- 'img-src': this.spriteSrc || preProcessSrc(this, this.src, style),
- 'img-placeholder': preProcessSrc(this, this.placeholder, style),
- 'sprite-src': this.spriteSrc,
- 'sprite-position': this.spritePosition,
- 'sprite-width': this.spriteWidth
- },
- on: createEventMap(this, ['load', 'error']),
- staticClass: 'weex-image weex-el',
- staticStyle: extend(style, customStyle)
- })
- },
- _css
-}
-
-export default {
- init (weex) {
- extractComponentStyle = weex.extractComponentStyle
- createEventMap = weex.createEventMap
- extend = weex.utils.extend
- isArray = weex.utils.isArray
-
- weex.registerComponent('image', image)
- weex.registerComponent('img', image)
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/components/index.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/index.js b/html5/render/vue/components/index.js
deleted file mode 100644
index 40219b8..0000000
--- a/html5/render/vue/components/index.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-import a from './a'
-import div from './div'
-import image from './image'
-import input from './input'
-import _switch from './switch'
-import scrollable from './scrollable'
-import slider from './slider'
-import text from './text'
-import textarea from './textarea'
-import video from './video'
-import web from './web'
-
-export default [
- a,
- div,
- image,
- input,
- _switch,
- scrollable,
- slider,
- text,
- textarea,
- video,
- web
-]
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/components/input.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/input.js b/html5/render/vue/components/input.js
deleted file mode 100644
index dcde6f0..0000000
--- a/html5/render/vue/components/input.js
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @fileOverview Input component.
- * Support v-model only if vue version is larger than 2.2.0
- */
-let extractComponentStyle, mapFormEvents, appendCss
-
-const ID_PREFIX_PLACEHOLDER_COLOR = 'wipt_plc_'
-const ID_PREFIX_INPUT = 'wipt_'
-let idCount = 0
-
-const _css = `
-.weex-input, .weex-textarea {
- font-size: 0.426667rem;
-}
-.weex-input:focus, .weex-textarea:focus {
- outline: none;
-}
-`
-
-function setPlaceholderColor (inputVm, placeholderColor) {
- if (!placeholderColor) {
- return
- }
- const vendors = [
- '::-webkit-input-placeholder',
- ':-moz-placeholder',
- '::-moz-placeholder',
- ':-ms-input-placeholder',
- ':placeholder-shown'
- ]
- const id = inputVm._id
- appendCss(
- vendors.map(function (vendor, idx) {
- return `#${ID_PREFIX_INPUT}${id}${vendors[idx]}{color:${placeholderColor};}`
- }).join(''),
- `${ID_PREFIX_PLACEHOLDER_COLOR}${id}`,
- true)
-}
-
-function processStyle (vm) {
- const styles = extractComponentStyle(vm)
- const phColor = styles.placeholderColor
- if (phColor) {
- setPlaceholderColor(vm, phColor)
- }
- return styles
-}
-
-function getInput (weex) {
- const { inputCommon } = weex.mixins
-
- return {
- name: 'weex-input',
- mixins: [inputCommon],
- props: {
- type: {
- type: String,
- default: 'text',
- validator (value) {
- return [
- 'email', 'number', 'password', 'search', 'tel', 'text', 'url', 'date',
- 'datetime', 'time'
- // unsupported type:
- // button, checkbox, color, file, hidden, image,
- // month, radio, range, reset, submit, week,
- ].indexOf(value) !== -1
- }
- },
- value: String,
- placeholder: String,
- disabled: {
- type: [String, Boolean],
- default: false
- },
- autofocus: {
- type: [String, Boolean],
- default: false
- },
- maxlength: [String, Number],
- returnKeyType: String
- },
-
- render (createElement) {
- if (!this._id) {
- this._id = idCount++
- }
- const events = mapFormEvents(this)
- return createElement('html:input', {
- attrs: {
- 'weex-type': 'input',
- id: `${ID_PREFIX_INPUT}${this._id}`,
- type: this.type,
- value: this.value,
- disabled: (this.disabled !== 'false' && this.disabled !== false),
- autofocus: (this.autofocus !== 'false' && this.autofocus !== false),
- placeholder: this.placeholder,
- maxlength: this.maxlength,
- 'returnKeyType': this.returnKeyType
- },
- domProps: {
- value: this.value
- },
- on: this.createKeyboardEvent(events),
- staticClass: 'weex-input weex-el',
- staticStyle: processStyle(this)
- })
- },
- _css
- }
-}
-
-export default {
- init (weex) {
- extractComponentStyle = weex.extractComponentStyle
- mapFormEvents = weex.utils.mapFormEvents
- appendCss = weex.utils.appendCss
-
- weex.registerComponent('input', getInput(weex))
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/components/scrollable/cell.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/scrollable/cell.js b/html5/render/vue/components/scrollable/cell.js
deleted file mode 100644
index e5e8301..0000000
--- a/html5/render/vue/components/scrollable/cell.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-
-function getCell (weex) {
- const { extractComponentStyle } = weex
- return {
- name: 'weex-cell',
- render (createElement) {
- return createElement('section', {
- attrs: { 'weex-type': 'cell' },
- staticClass: 'weex-cell weex-ct',
- staticStyle: extractComponentStyle(this)
- }, this.$slots.default)
- }
- }
-}
-
-export default {
- init (weex) {
- weex.registerComponent('cell', getCell(weex))
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/components/scrollable/header.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/scrollable/header.js b/html5/render/vue/components/scrollable/header.js
deleted file mode 100644
index 5abd78e..0000000
--- a/html5/render/vue/components/scrollable/header.js
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.
- */
-
-function getHeader (weex) {
- const { extractComponentStyle } = weex
- const { supportSticky } = weex.utils
-
- return {
- data () {
- return {
- sticky: false,
- initTop: 0,
- placeholder: null,
- supportSticky: supportSticky()
- }
- },
-
- mounted () {
- this.initTop = this.$el.offsetTop
- this.placeholder = window.document.createElement('header')
- },
-
- updated () {
- if (!this.sticky) {
- this.initTop = this.$el.offsetTop
- }
- },
-
- methods: {
- addSticky () {
- this.sticky = true
- this.placeholder.style.display = 'block'
- this.placeholder.style.width = this.$el.offsetWidth + 'px'
- this.placeholder.style.height = this.$el.offsetHeight + 'px'
- this.$el.parentNode.insertBefore(this.placeholder, this.$el)
- },
-
- removeSticky () {
- this.sticky = false
- try {
- this.$el.parentNode.removeChild(this.placeholder)
- }
- catch (e) {
- }
- }
- },
-
- render (createElement) {
- /* istanbul ignore next */
- // if (process.env.NODE_ENV === 'development') {
- // validateStyles('header', this.$vnode.data && this.$vnode.data.staticStyle)
- // }
- return createElement('html:header', {
- attrs: { 'weex-type': 'header' },
- ref: 'header',
- staticClass: 'weex-header weex-ct',
- class: { 'weex-sticky': this.sticky, 'weex-ios-sticky': this.supportSticky },
- staticStyle: extractComponentStyle(this)
- }, this.$slots.default)
- }
- }
-}
-
-export default {
- init (weex) {
- weex.registerComponent('header', getHeader(weex))
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/components/scrollable/index.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/scrollable/index.js b/html5/render/vue/components/scrollable/index.js
deleted file mode 100644
index 8142786..0000000
--- a/html5/render/vue/components/scrollable/index.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.
- */
-
-import list from './list'
-import scroller from './scroller'
-import waterfall from './waterfall'
-import cell from './cell'
-import header from './header'
-import loading from './loading'
-import refresh from './refresh'
-import loadingIndicator from './loading-indicator'
-
-import './style.css'
-
-const modules = [
- list,
- scroller,
- waterfall,
- cell,
- header,
- loading,
- refresh,
- loadingIndicator
-]
-
-export default {
- init (weex) {
- modules.forEach(function (mod) {
- weex.install(mod)
- })
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/components/scrollable/list.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/scrollable/list.js b/html5/render/vue/components/scrollable/list.js
deleted file mode 100644
index 77f8926..0000000
--- a/html5/render/vue/components/scrollable/list.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.
- */
-import { scrollable, list as listMixin } from './mixins'
-
-function getList (weex) {
- const {
- extractComponentStyle,
- createEventMap
- } = weex
-
- return {
- name: 'weex-list',
- mixins: [scrollable, listMixin],
- computed: {
- wrapperClass () {
- const classArray = ['weex-list', 'weex-list-wrapper', 'weex-ct']
- this._refresh && classArray.push('with-refresh')
- this._loading && classArray.push('with-loading')
- return classArray.join(' ')
- }
- },
-
- methods: {
- createChildren (h) {
- const slots = this.$slots.default || []
- this._cells = slots.filter(vnode => {
- if (!vnode.tag || !vnode.componentOptions) return false
- return true
- })
- return [
- h('article', {
- ref: 'inner',
- staticClass: 'weex-list-inner weex-ct'
- }, this._cells)
- ]
- }
- },
-
- render (createElement) {
- this.weexType = 'list'
-
- this.$nextTick(() => {
- this.updateLayout()
- })
-
- return createElement('main', {
- ref: 'wrapper',
- attrs: { 'weex-type': 'list' },
- staticClass: this.wrapperClass,
- on: createEventMap(this, {
- scroll: this.handleListScroll,
- touchstart: this.handleTouchStart,
- touchmove: this.handleTouchMove,
- touchend: this.handleTouchEnd
- }),
- staticStyle: extractComponentStyle(this)
- }, this.createChildren(createElement))
- }
- }
-}
-
-export default {
- init (weex) {
- weex.registerComponent('list', getList(weex))
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ceef728d/html5/render/vue/components/scrollable/loading-indicator.js
----------------------------------------------------------------------
diff --git a/html5/render/vue/components/scrollable/loading-indicator.js b/html5/render/vue/components/scrollable/loading-indicator.js
deleted file mode 100644
index 4fa2c7b..0000000
--- a/html5/render/vue/components/scrollable/loading-indicator.js
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * 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.
- */
-let extractComponentStyle, getRgb, loopArray, getStyleSheetById
-
-const _css = `
-.weex-refresh-indicator,
-.weex-loading-indicator {
- width: 1rem !important;
- height: 1rem !important;
- -webkit-box-align: center;
- -moz-box-align: center;
- -webkit-align-items: center;
- -ms-flex-align: center;
- align-items: center;
- -webkit-box-pack: center;
- -moz-box-pack: center;
- -webkit-justify-content: center;
- -ms-flex-pack: center;
- justify-content: center;
- overflow: visible;
- background: none;
-}
-.weex-refresh-indicator:before,
-.weex-loading-indicator:before {
- display: block;
- content: '';
- font-size: 0.16rem;
- width: 0.5em;
- height: 0.5em;
- left: 0;
- top: 0;
- border-radius: 50%;
- position: relative;
- text-indent: -9999em;
- -webkit-animation: weex-spinner 1.1s infinite ease;
- -moz-animation: weex-spinner 1.1s infinite ease;
- animation: weex-spinner 1.1s infinite ease;
-}
-
-@-webkit-keyframes weex-spinner {
- 0%,
- 100% {
- box-shadow: 0em -1.3em 0em 0em #ffffff, 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2), 1.25em 0em 0 0em rgba(255, 255, 255, 0.2), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.2), 0em 1.25em 0 0em rgba(255, 255, 255, 0.2), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.2), -1.3em 0em 0 0em rgba(255, 255, 255, 0.5), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.7);
- }
- 11.25% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.7), 0.9em -0.9em 0 0em #ffffff, 1.25em 0em 0 0em rgba(255, 255, 255, 0.2), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.2), 0em 1.25em 0 0em rgba(255, 255, 255, 0.2), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.2), -1.3em 0em 0 0em rgba(255, 255, 255, 0.2), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.5);
- }
- 25% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.5), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.7), 1.25em 0em 0 0em #ffffff, 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.2), 0em 1.25em 0 0em rgba(255, 255, 255, 0.2), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.2), -1.3em 0em 0 0em rgba(255, 255, 255, 0.2), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2);
- }
- 37.5% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.2), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.5), 1.25em 0em 0 0em rgba(255, 255, 255, 0.7), 0.875em 0.875em 0 0em #ffffff, 0em 1.25em 0 0em rgba(255, 255, 255, 0.2), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.2), -1.3em 0em 0 0em rgba(255, 255, 255, 0.2), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2);
- }
- 50% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.2), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2), 1.25em 0em 0 0em rgba(255, 255, 255, 0.5), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.7), 0em 1.25em 0 0em #ffffff, -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.2), -1.3em 0em 0 0em rgba(255, 255, 255, 0.2), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2);
- }
- 61.25% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.2), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2), 1.25em 0em 0 0em rgba(255, 255, 255, 0.2), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.5), 0em 1.25em 0 0em rgba(255, 255, 255, 0.7), -0.9em 0.9em 0 0em #ffffff, -1.3em 0em 0 0em rgba(255, 255, 255, 0.2), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2);
- }
- 75% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.2), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2), 1.25em 0em 0 0em rgba(255, 255, 255, 0.2), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.2), 0em 1.25em 0 0em rgba(255, 255, 255, 0.5), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.7), -1.3em 0em 0 0em #ffffff, -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2);
- }
- 87.5% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.2), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2), 1.25em 0em 0 0em rgba(255, 255, 255, 0.2), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.2), 0em 1.25em 0 0em rgba(255, 255, 255, 0.2), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.5), -1.3em 0em 0 0em rgba(255, 255, 255, 0.7), -0.9em -0.9em 0 0em #ffffff;
- }
-}
-
-@keyframes weex-spinner {
- 0%,
- 100% {
- box-shadow: 0em -1.3em 0em 0em #ffffff, 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2), 1.25em 0em 0 0em rgba(255, 255, 255, 0.2), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.2), 0em 1.25em 0 0em rgba(255, 255, 255, 0.2), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.2), -1.3em 0em 0 0em rgba(255, 255, 255, 0.5), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.7);
- }
- 11.25% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.7), 0.9em -0.9em 0 0em #ffffff, 1.25em 0em 0 0em rgba(255, 255, 255, 0.2), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.2), 0em 1.25em 0 0em rgba(255, 255, 255, 0.2), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.2), -1.3em 0em 0 0em rgba(255, 255, 255, 0.2), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.5);
- }
- 25% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.5), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.7), 1.25em 0em 0 0em #ffffff, 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.2), 0em 1.25em 0 0em rgba(255, 255, 255, 0.2), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.2), -1.3em 0em 0 0em rgba(255, 255, 255, 0.2), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2);
- }
- 37.5% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.2), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.5), 1.25em 0em 0 0em rgba(255, 255, 255, 0.7), 0.875em 0.875em 0 0em #ffffff, 0em 1.25em 0 0em rgba(255, 255, 255, 0.2), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.2), -1.3em 0em 0 0em rgba(255, 255, 255, 0.2), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2);
- }
- 50% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.2), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2), 1.25em 0em 0 0em rgba(255, 255, 255, 0.5), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.7), 0em 1.25em 0 0em #ffffff, -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.2), -1.3em 0em 0 0em rgba(255, 255, 255, 0.2), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2);
- }
- 61.25% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.2), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2), 1.25em 0em 0 0em rgba(255, 255, 255, 0.2), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.5), 0em 1.25em 0 0em rgba(255, 255, 255, 0.7), -0.9em 0.9em 0 0em #ffffff, -1.3em 0em 0 0em rgba(255, 255, 255, 0.2), -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2);
- }
- 75% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.2), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2), 1.25em 0em 0 0em rgba(255, 255, 255, 0.2), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.2), 0em 1.25em 0 0em rgba(255, 255, 255, 0.5), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.7), -1.3em 0em 0 0em #ffffff, -0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2);
- }
- 87.5% {
- box-shadow: 0em -1.3em 0em 0em rgba(255, 255, 255, 0.2), 0.9em -0.9em 0 0em rgba(255, 255, 255, 0.2), 1.25em 0em 0 0em rgba(255, 255, 255, 0.2), 0.875em 0.875em 0 0em rgba(255, 255, 255, 0.2), 0em 1.25em 0 0em rgba(255, 255, 255, 0.2), -0.9em 0.9em 0 0em rgba(255, 255, 255, 0.5), -1.3em 0em 0 0em rgba(255, 255, 255, 0.7), -0.9em -0.9em 0 0em #ffffff;
- }
-}
-`
-
-function getStyleSheet (spinnerVm) {
- if (spinnerVm._styleSheet) {
- return
- }
- spinnerVm._styleSheet = getStyleSheetById('weex-cmp-loading-indicator')
-}
-
-function setKeyframeColor (spinnerVm, val) {
- getStyleSheet(spinnerVm)
- const keyframeRules = computeKeyFrameRules(val)
- const rules = spinnerVm._styleSheet.rules || spinnerVm._styleSheet.cssRules
- for (let i = 0, l = rules.length; i < l; i++) {
- const item = rules.item(i)
- if ((item.type === CSSRule.KEYFRAMES_RULE
- || item.type === CSSRule.WEBKIT_KEYFRAMES_RULE)
- && item.name === 'weex-spinner') {
- const cssRules = item.cssRules
- for (let j = 0, m = cssRules.length; j < m; j++) {
- const keyframe = cssRules[j]
- if (keyframe.type === CSSRule.KEYFRAME_RULE
- || keyframe.type === CSSRule.WEBKIT_KEYFRAME_RULE) {
- keyframe.style.boxShadow = keyframeRules[j]
- }
- }
- }
- }
-}
-
-function computeKeyFrameRules (rgb) {
- if (!rgb) {
- return
- }
- const scaleArr = [
- '0em -1.3em 0em 0em',
- '0.9em -0.9em 0 0em',
- '1.25em 0em 0 0em',
- '0.875em 0.875em 0 0em',
- '0em 1.25em 0 0em',
- '-0.9em 0.9em 0 0em',
- '-1.3em 0em 0 0em',
- '-0.9em -0.9em 0 0em']
- const colorArr = [
- '1',
- '0.2',
- '0.2',
- '0.2',
- '0.2',
- '0.2',
- '0.5',
- '0.7'].map(function (e) {
- return 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + e + ')'
- })
- const rules = []
- for (let i = 0; i < scaleArr.length; i++) {
- const tmpColorArr = loopArray(colorArr, i, 'r')
- rules.push(scaleArr.map(function (scaleStr, i) {
- return scaleStr + ' ' + tmpColorArr[i]
- }).join(', '))
- }
- return rules
-}
-
-function processStyle (vm) {
- const style = extractComponentStyle(vm)
- const color = style.color
- const rgb = color && getRgb(color)
- if (rgb) {
- setKeyframeColor(vm, rgb)
- }
- return style
-}
-
-const loadingIndicator = {
- name: 'weex-loading-indicator',
- render (createElement) {
- this.weexType = 'loading-indicator'
- return createElement('mark', {
- attrs: { 'weex-type': 'loading-indicator' },
- staticClass: 'weex-loading-indicator weex-ct',
- staticStyle: processStyle(this)
- })
- },
- _css
-}
-
-export default {
- init (weex) {
- extractComponentStyle = weex.extractComponentStyle
- getRgb = weex.utils.getRgb
- loopArray = weex.utils.loopArray
- getStyleSheetById = weex.utils.getStyleSheetById
- weex.registerComponent('loading-indicator', loadingIndicator)
- }
-}