src/js/model.js
branchnew-model
changeset 881 f11b234497f7
parent 880 4c7b33bf2795
child 887 6a04bd37da0a
--- a/src/js/model.js	Thu Apr 26 19:18:57 2012 +0200
+++ b/src/js/model.js	Fri Apr 27 19:18:21 2012 +0200
@@ -73,9 +73,14 @@
 IriSP.Model.List.prototype = new Array();
 
 IriSP.Model.List.prototype.getElement = function(_id) {
-    var _index = (IriSP._(this.idIndex).indexOf(this.source.getNamespaced(_id).fullName));
+    var _index = IriSP._(this.idIndex).indexOf(_id);
     if (_index !== -1) {
         return this[_index];
+    } else {
+        var _un = _id.replace(/.*:/);
+        return IriSP._(this.idIndex).find(function(_i) {
+            return _i.replace(/.*:/) === _un;
+        });
     }
 }
 
@@ -538,7 +543,7 @@
 }
 
 IriSP.Model.Source.prototype.getElement = function(_elId) {
-    return this.directory.getElement(_this.getNamespaced(_elId).fullname);
+    return this.directory.getElement(this.getNamespaced(_elId).fullname);
 }
 
 IriSP.Model.Source.prototype.setCurrentMediaId = function(_idRef) {
@@ -680,7 +685,18 @@
 }
 
 IriSP.Model.Directory.prototype.getElement = function(_id) {
-    return this.elements[_id];
+    var _res = this.elements[_id];
+    if (typeof _res === "undefined") {
+        var _un = _id.replace(/.*:/),
+            _keys = IriSP._(this.elements).keys();
+            _key = IriSP._(_keys).find(function(_i) {
+                return _i.replace(/.*:/) === _un;
+            });
+        if (typeof _key !== "undefined") {
+            _res = this.elements[_key];
+        }
+    }
+    return _res;
 }
 
 IriSP.Model.Directory.prototype.addElement = function(_element) {