-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
459 additions
and
17 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @file mip-story-jsmpeg 组件 | ||
* @author | ||
*/ | ||
|
||
define(function (require) { | ||
'use strict'; | ||
|
||
var customElement = require('customElement').create(); | ||
var util = require('util'); | ||
var dm = util.dom; | ||
|
||
function getAttributeSet(attributes) { | ||
var attrs = {}; | ||
Array.prototype.slice.apply(attributes).forEach(function (attr) { | ||
attrs[attr.name] = attr.value; | ||
}); | ||
return attrs; | ||
} | ||
|
||
function getJsonString(attrs) { | ||
var attrString = ''; | ||
for (var prop in attrs){ | ||
attrString += prop + '=' + attrs[prop] + ' '; | ||
} | ||
return attrString | ||
} | ||
|
||
customElement.prototype.initStoryImg = function () { | ||
this.attributes = getAttributeSet(this.element.attributes); | ||
var attrString = getJsonString(this.attributes); | ||
var imgHtml = '<mip-img ' + attrString + '></mip-img>'; | ||
var storyImg = dm.create(imgHtml); | ||
this.element.parentNode.insertBefore(storyImg, this.element); | ||
} | ||
|
||
customElement.prototype.attributeChangedCallback = function () { | ||
if (this.element.hasAttribute('preload')) { | ||
this.initStoryImg(); | ||
} | ||
}; | ||
|
||
customElement.prototype.firstInviewCallback = function () { | ||
}; | ||
|
||
/* eslint-disable */ | ||
MIP.registerMipElement('mip-story-img', customElement); | ||
|
||
return customElement; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters