' + html;
if(typeof(GigList_callbacks.loaded)=='function') { GigList_callbacks.loaded(); }
}
},
search: {
DEFAULT: 'Live Search',
ENDPOINT: 'http://behance.net/services/giglist/jobs/',
MIN_DELAY: 200,
POLL: 225,
SAMPLE: 'e.g. “Designer in Los Angeles” or “Ruby Programmer in New York”',
SEARCH_INPUT: document.getElementById('giglist_search'),
REALM_WRAP : document.getElementById('giglist_realms_wrap'),
SEARCH_REALM : function () { return (document.getElementById('giglist_realms') || false) },
SEARCH_FORM: document.getElementById('giglist_search_form'),
INIT_CALLBACK_CALLED : false,
lastKeyPress: null,
lastSearch: '',
lastSearchDirty: '',
page: 1,
scrub: function(str) {
str = str.replace(/^\s+/, '');
str = str.replace(/\s+$/, '');
return str;
},
inputFocus: function() {
var self = GigList.search;
if (self.SEARCH_INPUT.value === self.DEFAULT) {
self.SEARCH_INPUT.value = '';
}
},
inputBlur: function() {
var self = GigList.search;
if (self.SEARCH_INPUT.value === '') {
self.SEARCH_INPUT.value = self.DEFAULT;
}
},
refreshJobs: function() {
var self = GigList.search;
var newString = self.SEARCH_INPUT.value;
if (newString === self.DEFAULT) { newString = ''; }
if (newString === self.lastSearchDirty) { return; }
var newStringScrubbed = self.scrub(newString);
if (self.lastSearch === newStringScrubbed) { return; }
var diff = self.MIN_DELAY;
if (self.lastKeyPress !== null) {
diff = (new Date).getTime() - self.lastKeyPress;
}
self.lastKeyPress = (new Date).getTime();
if (self.MIN_DELAY < diff) {
self.lastSearch = newStringScrubbed;
self.lastSearchDirty = newString;
self.page = 1;
self.refresh();
}
},
refresh: function() {
var self = GigList.search;
self.SEARCH_INPUT.setAttribute('class', 'searching');
self.SEARCH_INPUT.setAttribute('className', 'searching');
var fullReq = self.ENDPOINT +
encodeURIComponent(self.lastSearch) +
'/' + self.page + '/' + ((!self.SEARCH_REALM())? 'all' : self.SEARCH_REALM().value) + '/&callback=GigList.search.loaded';
GigList.remote.load(fullReq);
},
repage: function(url) {
var self = GigList.search;
var arr = url.split('/');
GigList.search.page = arr[arr.length - 2];
window.location.hash = 'giglist_content';
self.refresh();
},
loaded: function(html) {
var self = GigList.search;
GigList.CONTENT.innerHTML = html;
self.SEARCH_INPUT.setAttribute('class', '');
self.SEARCH_INPUT.setAttribute('className', '');
if(!GigList.jobs.INIT_CALLBACK_CALLED && typeof(GigList_callbacks.load_callback)=='function') {
GigList.jobs.INIT_CALLBACK_CALLED = true;
GigList_callbacks.load_callback();
}
}
},
/* GigList.Browser was taken from Prototype, and is subject to the following license:
*
* Prototype JavaScript framework, version 1.5.1_rc2
* (c) 2005-2007 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
* For details, see the Prototype web site: http://www.prototypejs.org/
*
/*--------------------------------------------------------------------------*/
Browser: {
IE: !!(window.attachEvent && !window.opera),
Opera: !!window.opera,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1
},
/*
GigList.mochikit was taken from MochiKit 1.3.1, and is subject to the
following license:
See for documentation, downloads, license, etc.
(c) 2005 Bob Ippolito. All rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
mochikit: {
queryString: function (names) {
var o = names;
names = [];
values = [];
for (var k in o) {
var v = o[k];
if (typeof(v) == "function") {
continue;
} else if (typeof(v) != "string" &&
typeof(v.length) == "number") {
for (var i = 0; i < v.length; i++) {
names.push(k);
values.push(v[i]);
}
} else {
names.push(k);
values.push(v);
}
}
var rval = [];
var len = Math.min(names.length, values.length);
for (var i = 0; i < len; i++) {
v = values[i];
if (typeof(v) != 'undefined' && v !== null) {
rval.push(encodeURIComponent(names[i]) + "=" + encodeURIComponent(v));
}
}
return rval.join("&");
},
parseQueryString: function (encodedString, useArrays) {
var pairs = encodedString.replace(/\+/g, "%20").split("&");
var o = {};
var decode;
if (typeof(decodeURIComponent) != "undefined") {
decode = decodeURIComponent;
} else {
decode = unescape;
}
if (useArrays) {
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i].split("=");
if (pair.length !== 2) {
continue;
}
var name = decodeURIComponent(pair[0]);
var arr = o[name];
if (!(arr instanceof Array)) {
arr = [];
o[name] = arr;
}
arr.push(decodeURIComponent(pair[1]));
}
} else {
for (i = 0; i < pairs.length; i++) {
pair = pairs[i].split("=");
if (pair.length !== 2) {
continue;
}
o[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
}
return o;
}
}
};
if (GigList.jobs.jobIsShowing() === true) {
GigList.jobs.show();
} else {
GigList.remote.loadRealmOpts();
GigList.search.refresh();
setInterval(function() { GigList.search.refreshJobs(); }, GigList.search.POLL);
}