forked from select2/select2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should allow us to create a basic interface that all adapters must follow.
- Loading branch information
1 parent
08ac13d
commit 114732e
Showing
8 changed files
with
163 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
define([ | ||
'../utils' | ||
], function (Utils) { | ||
function BaseAdapter ($element, options) { | ||
BaseAdapter.__super__.constructor.call(this); | ||
} | ||
|
||
Utils.Extend(BaseAdapter, Utils.Observable); | ||
|
||
BaseAdapter.prototype.current = function (callback) { | ||
throw new Error("The `current` method must be defined in child classes."); | ||
} | ||
|
||
BaseAdapter.prototype.query = function (params, callback) { | ||
throw new Error("The `query` method must be defined in child classes."); | ||
} | ||
|
||
return BaseAdapter; | ||
}); |
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,29 @@ | ||
module("Data adapters - Base") | ||
|
||
var BaseData = require("select2/data/base"); | ||
var $ = require("jquery"); | ||
var Options = require("select2/options"); | ||
|
||
var options = new Options({}); | ||
|
||
test("current is required", function (assert) { | ||
var data = new BaseData($("#qunit-fixture select"), options); | ||
|
||
assert.throws( | ||
function () { | ||
data.current(function () {}); | ||
}, | ||
"current has no default implementation" | ||
) | ||
}); | ||
|
||
test("query is required", function (assert) { | ||
var data = new BaseData($("#qunit-fixture select"), options); | ||
|
||
assert.throws( | ||
function () { | ||
data.query({}, function () {}); | ||
}, | ||
"query has no default implementation" | ||
); | ||
}); |
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,20 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="../vendor/qunit-1.14.0.css" type="text/css" /> | ||
<link rel="stylesheet" href="../../dist/css/select2.css" type="text/css" /> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"> | ||
<select></select> | ||
</div> | ||
|
||
<script src="../vendor/qunit-1.14.0.js" type="text/javascript"></script> | ||
<script src="../../vendor/almond-0.2.9.js" type="text/javascript"></script> | ||
<script src="../../vendor/jquery-2.1.0.js" type="text/javascript"></script> | ||
<script src="../../dist/js/select2.amd.js" type="text/javascript"></script> | ||
|
||
<script src="base-tests.js" type="text/javascript"></script> | ||
</body> | ||
</html> |