Skip to content

Commit

Permalink
add util for correct extend objects
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-gribanov committed Jan 27, 2017
1 parent c4a2383 commit eae920f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Create control
var ControlFormDate = function() {
};

$.extend(ControlFormDate, ControllerControl);
extend(ControlFormDate, ControllerControl);

ControlFormDate.prototype.bind = function(target) {
target.datepicker({dateFormat: 'yy-mm-dd'});
Expand Down Expand Up @@ -42,6 +42,7 @@ Use in HTML

<script src="/node_modules/gpslab-controller/src/Controller/Control.js"></script>
<script src="/node_modules/gpslab-controller/src/Controller.js"></script>
<script src="/node_modules/gpslab-controller/src/util/extend.js"></script>
<script src="/js/ControlFormDate.js"></script>
<script src="/js/common.js"></script>

Expand Down Expand Up @@ -117,7 +118,7 @@ var ControlLock = function(locker) {
this._locker = locker; // private
};

$.extend(ControlLock, ControllerControl);
extend(ControlLock, ControllerControl);

ControlLock.prototype.bind = function(target) {
var that = this;
Expand Down Expand Up @@ -150,6 +151,7 @@ Use in HTML
<script src="/node_modules/gpslab-controller/src/Controller/Control.js"></script>
<script src="/node_modules/gpslab-controller/src/Controller.js"></script>
<script src="/node_modules/gpslab-controller/src/util/Locker.js"></script>
<script src="/node_modules/gpslab-controller/src/util/extend.js"></script>
<script src="/js/ControlLock.js"></script>
<script src="/js/common.js"></script>

Expand Down Expand Up @@ -233,7 +235,7 @@ var ControlLock = function(locker) {
this._locker = locker; // private
};

$.extend(ControlLock, ControllerControl);
extend(ControlLock, ControllerControl);

ControlLock.prototype.bind = function(target) {
new ControlLockContainer(target, this._locker);
Expand Down Expand Up @@ -273,7 +275,7 @@ var ControlAppend = function(element, controller) {
this._controller = controller; // private
};

$.extend(ControlLock, ControlAppend);
extend(ControlLock, ControlAppend);

ControlAppend.prototype.bind = function(target) {
new ControlAppendContainer(target, this._element, this._controller);
Expand Down Expand Up @@ -303,6 +305,7 @@ Use in HTML

<script src="/node_modules/gpslab-controller/src/Controller/Control.js"></script>
<script src="/node_modules/gpslab-controller/src/Controller.js"></script>
<script src="/node_modules/gpslab-controller/src/util/extend.js"></script>
<script src="/js/ControlAppendContainer.js"></script>
<script src="/js/ControlAppend.js"></script>
<script src="/js/ControlFormDate.js"></script>
Expand Down
8 changes: 8 additions & 0 deletions src/util/extend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

function extend(Child, Parent) {
var F = function() {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.prototype.constructor = Child;
Child.superclass = Parent.prototype;
}

0 comments on commit eae920f

Please sign in to comment.